IdCreator
IdCreator is a helper for creating unique id's in your Vaadin UI.
If you're doing TestBench or JMeter testing in your application, you have to set sane, unique id's for your UI components. But in a dynamic UI this can be more difficult than it needs to be.
IdCreator helps in this by creating "component paths" that are automatically used as id's. The component paths are created by using simple interfaces that your components can implement, so only the components you choose participate in building the full path for a single component.
As an example (from the demo), given the UI is set as the id path root, and there are id path components "container" and "innerlayout", calling IdCreator.setId(field, "textfield") would set "demoUI-container-child-0-innerlayout-textfield" as the id of the field.
Sample code
// the root of some component path, typically the UI public class IdCreatorDemoUI extends UI implements IdPathRoot { ... @Override public String idStringFromChild(Component child) { return "demoUI"; } } //one component in the path public class ContainerLayout extends VerticalLayout implements IdPathComponent { ... @Override public String idStringFromChild(Component child) { if (child != null) { return IdCreator.childString("container", getComponentIndex(child)); } else { return "container"; } } } //and finally setting the actual id, which will the full path from this component to the root //e.g. "demoUI-container-child-0-innerlayout-textfield" IdCreator.setId(field, "textfield");
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
- Released
- 2013-06-02
- Maturity
- BETA
- License
- Apache License 2.0
Compatibility
- Framework
- Vaadin 7.0+
- Browser
- Browser Independent
IdCreator - Vaadin Add-on Directory
IdCreator is a helper for creating unique id's in your Vaadin UI.Online Demo
Issue Tracker
Source Code