Java tutorial
/* * Copyright 2009-2013 Hippo B.V. (http://www.onehippo.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.hippoecm.frontend.plugins.yui.layout; import java.io.Serializable; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; /** * The YuiId allows for transparent element id resolution, without having to worry about id clashes on the client. * * The idea is really simple. A YuiId consists of an id value, and an optional parentId value. If the parentId is set, * the YuiId will return an elementId like 'parentId:id', else it will only return the local id. * * The id value corresponds to an element in a {@link org.apache.wicket.Component}'s html file through the attribute * yui:id, the parent id is a normal id-attribute, normally generated by Wicket and added to the YuiId once it's known. * * The YAHOO.hippo.LayoutManager module uses YAHOO.hippo.Dom.resolveElement(id) to resolve elements by their YuiId. * For more info see: * hippo-ecm-addon-yui/src/main/java/org/hippoecm/frontend/plugins/yui/inc/hippo/2.7.0/hippodom/hippodom.js */ public class YuiId implements Serializable { private static final long serialVersionUID = 1L; private String id; private String parentId; public YuiId(String id) { this.id = id; } public String getElementId() { if (parentId != null && !"".equals(parentId)) { if (id != null && !"".equals(id)) { return parentId + ":" + id; } } else { return id; } return ""; } public void setId(String id) { this.id = id; } public String getId() { return id; } public String getParentId() { return parentId; } public void setParentId(String parentId) { this.parentId = parentId; } @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("id", id) .append("parentId", parentId).toString(); } }