0

I'm pretty new to JSF (Just 1 week old) and developing first component. Component is something like a table which takes a collection as input and renders the contents in a table format. In addition to that renders a "Remove" link at the end of each row.

I created "Composite" component (.xhtml) and ComponentType (a java class with @FacesComponent).

I got the complete table rendering and "Remove" link is displayed in each row. Now trying to add with action that is defined in my class with @FacesComponent.

<a4j:commandLink action="#{cc.removeRow(rowKey)}" value="Remove"/>

In my component (java class) I have this method removeRow(Integer rowKey) defined. But on clicking this "Remove" link the action is not triggered. I have "h:form" also defined in the component.

Any help or pointers is much appreciated.

EDITED: just looked at this question How to implement a dynamic list with a JSF 2.0 Composite Component? and it resembles almost my requirement. Just one thing I'm not sure is what would be the form action when it is rendered and if I click the button in the component, how it would call the method inside its own component bean.

Community
  • 1
  • 1
Murali Murugesan
  • 105
  • 1
  • 11

1 Answers1

0

Ok, this is the mistake I was doing.

I'm rendering a custom table using Guava "Table" Collection. This initialization of table happens in "encodeBegin" which was called once. So when I clicked on submit it was trying to re-render the table and it sees everything as null and hence throws NPE.

I now extracted the initialization of table to a separate method and a helper method to retrieve existing table if it's not null or re-initialize from the attributes.

It works now.

Murali Murugesan
  • 105
  • 1
  • 11