my dog learned polymorphism*
The moose likes JSF and the fly likes custom component problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "custom component problem" Watch "custom component problem" New topic
Author

custom component problem

Ziji (Jay) Zhang
Ranch Hand

Joined: Dec 17, 2004
Posts: 42
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!


SCJP(94%)
 
Don't get me started about those stupid light bulbs.
 
subject: custom component problem