* component, the mapping from c to the string is removed. Similarly, if
* component was mapped to some string s different from localId, the mapping
* from s to component is removed.
+ *
* @param component
* The component whose local id is to be set.
* @param localId
componentToLocalId);
}
+ /**
+ * Returns the local id for a component
+ *
+ * @param component
+ * The component whose local id to get.
+ * @return the local id of the component, or null if the component has no
+ * local id assigned
+ */
+ public String getComponentLocalId(Component component) {
+ return componentToLocalId.get(component);
+ }
+
/**
* Creates a mapping between the given caption and the component. Returns
* true if caption was already mapped to some component.
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.SingleComponentContainer;
import com.vaadin.ui.TabSheet;
.getElementsByTag("v-button").first().attr("_id"));
}
}
+
+ @Test
+ public void testGetLocalId() {
+ DesignContext ctx = new DesignContext();
+ Label label = new Label();
+ ctx.setComponentLocalId(label, "my-local-id");
+ ctx.setRootComponent(label);
+ assertEquals("my-local-id", ctx.getComponentLocalId(label));
+ }
}