Hi, it's me again...
Well I still get an error about duplicate Ids -- but only when I
generate them on my own. If I don't do anything about them (and ignore
the warnings) everything's fine...
Thats the code snippet:
...
HtmlCommandLink instanceLink = new HtmlCommandLink();
////
instanceLink.setId(PROPERTIES_PANEL_ID + "m" + root.createUniqueId());
////
instanceLink.setValue(subnode.getCaption());
PropertyPageController ppcontroller = new PropertyPageController(subnode);
instanceLink.addActionListener(ppcontroller);
panel.getChildren().add(instanceLink);
...
The exception thrown is:
javax.servlet.ServletException: cannot add component with id '_id357'
and path : {Component-Path : [Class: javax.faces.component.UIOutput,Id:
_id357]} to its parent component. This might be a problem due to
duplicate ids.
So, what's going wrong here?
- Marius
Volker Weber wrote:
Hi,
Marius Kreis wrote:
Hi!
You're right, the cause of this exception is a verbatim tag, I was not
aware that the verbatim tag is getting an id aswell and this might cause
the exception...
the complete jsp is:
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles"
prefix="tiles" %>
<f:view>
<f:verbatim>
<html>
<head>
<link href="styles/main.css" rel="stylesheet" type="text/css">
</head>
<body>
</f:verbatim>
<h:commandLink value="#{test.name}">
<f:actionListener type="my.domain.Test" />
</h:commandLink>
<h:panelGrid id="panel" rowClasses="oddRow, evenRow">
</h:panelGrid>
<f:verbatim>
</body>
</html>
</f:verbatim>
</f:view>
When I remove the verbatim tag (by putting the f:view tags only around
the commandLink and panelGrid) everything seems to work fine.
I don't know the reason to put those html tags inside of verbatim, but i
often see this.
if i use html i wrote it directly into the jsp.
@all: Is there a advantage for puting html into verbatim instead of direct?
In fact there are warnings that the id's were generated automatically
and that the should be generated using root.createUniqueId() -- but only
when I use this function, I end up with duplicate ids -- perhaps I have
to concatenate the generated id and the id of my parent element (the
panelGrid)?
I prefer concatenating parendsId + '_' + index as the id.