Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

custom component problem

 
Ziji (Jay) Zhang
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the jsp page that using my
custom component that I developed. The tag syntax try to follow Tree2 implementation of the Tomahawk project.

<rfbjectPanel numColumns="3" value="#{userData.users}" var="user" varSelector="s" >
<f:facet name="ICON1_TYPE">
<h:panelGroup id="pg1" >
<h:commandLink immediate="true" actionListener="#{s.setItemSelected}">
<h:graphicImage value="/user1Icon.jpg"/>
<hutputText value="#{user.name}"/>
<f:param name="paramOne" value="#{user.name}" />
</h:commandLink>
</h:panelGroup>
</f:facet>

....

</rfbjectPanel>

In Renderer, the facet will be rendered as table grid. depending on the number of users in the userData object,
a number of Icon & username will be renderer a a list in a pannel.

The <f:param name="paramOne" /> is supposed to be
posted back to the server, on the client side, the javascript
generated by Framework will send paramOne as hidden field when
user click the commandlink. But when the ActionListener called back, I try to get the param value from
the ActionEvent, but the paramOne value is alway null. Could anyone give me some hint for this problem??

BTW, if I hard-coded the paramONe value in jsp page,
everything is fine.


This method is in the sub-class of UIComponentBase class (called UIObjectPanel), the UIObjectPanel object is
exposed by value binding as indicated in the Tag, varSelector="s", in the UIObjectPanel class,
s is mapped to this UIComponent subclass by value binding.

I have declared userData as managed bean with session scope.
Here is the EventHandler when user click commandLink:

public void setItemSelected(ActionEvent event){

log.debug("command button id : " +event.getComponent().getId());
List children = event.getComponent().getChildren();
log.debug("number of child : " + children.size());
for( int i =0; i <children.size(); i++){
Object obj = children.get(i);

if (children.get(i) instanceof UIParameter ){
UIParameter currentParam = (UIParameter)children.get(i);
log.debug("param name : " + currentParam.getName() +"; param value : "+ currentParam.getValue());
if (currentParam.getName().equals("itemId") && currentParam.getValue() != null){
String paramValue = currentParam.getValue().toString();
log.debug("param value for itemId : " + paramValue);
((ListDataModelWithState)getDataModel()).getState().setSelected(paramValue);
}}}}

Thank you very much in advance!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic