* @return form relative identification string
*/
public static String getRootFormRelativeId(Component component)
{
String id = component.getId();
final PrependingStringBuffer inputName = new PrependingStringBuffer(id.length());
Component c = component;
while (true)
{
inputName.prepend(id);
c = c.getParent();
if (c == null || (c instanceof Form<?> && ((Form<?>)c).isRootForm()) ||
c instanceof Page)
{
break;
}
inputName.prepend(Component.PATH_SEPARATOR);
id = c.getId();
}
/*
* having input name "submit" causes problems with JavaScript, so we create a unique string
* to replace it by prepending a path separator, as this identification can be assigned to
* an submit form component name
*/
if ("submit".equals(inputName.toString()))
{
inputName.prepend(Component.PATH_SEPARATOR);
}
return inputName.toString();
}