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.

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)?



Volker Weber wrote:
Hallo,

you should post a litle more of your code, the exception occures in a
verbatim tag, i can't see a verbatim tag in your posted code.

so just a guess:

could be a problem with ids: you should assign an id to every created
component.

if on one request one of your commandlinks became a automatic assigned
id '_id<xy>' and in a second request this id is assigned to an verbatim
tag then this can occur.

If this is the problem you should found a warning in your log files.

Regards
  Volker

Marius Kreis wrote:

hello!
i'm still working on generating a _simple_ list of hyperlinks.
but when i click on one of them a ClassCastException is thrown.

at first i thought about an error with the ActionListener, but in fact
the exception is thrown even if there was no actionlistener assigned at
all.

i just can't figure out whats going wrong......

my jsp looks like this:

<h:commandLink value="#{test.name}">
<f:actionListener type="my.domain.Test" />
</h:commandLink>

<h:panelGrid id="panel" rowClasses="oddRow, evenRow">
</h:panelGrid>



whereas the Test bean looks like this:

...
public void action(ActionEvent e) {
   System.out.println("Action triggered");
}

public void processAction(ActionEvent actionEvent)
   throws AbortProcessingException {
       UIComponent   component = actionEvent.getComponent();
       FacesContext  facesContext = FacesContext.getCurrentInstance();
       UIViewRoot    root = facesContext.getViewRoot();
       Application   application = facesContext.getApplication();

       HtmlPanelGrid panel = (HtmlPanelGrid) root.findComponent("panel");

       for(int i = 1; i <= 10; i++)
       {
           HtmlCommandLink instanceLink = new HtmlCommandLink();
           instanceLink.setValue("Link #" + i);

   // doesn matter if this part is included or not...
           Class[] param = new Class[] { ActionEvent.class };
           MethodBinding actionListener =
application.createMethodBinding("#{test.action}", param);
           instanceLink.setActionListener(actionListener);
   // ....

           panel.getChildren().add(instanceLink);
       }
   }

   public String getName() { return "click it"; }
...


and that's what the exception trace looks like:

java.lang.ClassCastException: javax.faces.component.html.HtmlCommandLink
   at
org.apache.myfaces.taglib.core.VerbatimTag.doAfterBody(VerbatimTag.java:76)
   at
org.apache.jsp.test_jsp._jspx_meth_f_verbatim_1(org.apache.jsp.test_jsp:256)

...

seems as if a UICommand component is casted to an UIOutput component....
 but why?!




Reply via email to