Thanks a lot Sean! I must have had the wrong idea about what the identifier is in the first place. Now it makes a whole lot of more sense.

Thanks,

Andreas

Sean Schofield wrote:

Did you set the node identifier?  Its not populated by default.  So
when you are creating your hierarchy of tree node data you need to set
it to something meaningful.

sean

On 9/29/05, Andreas Lund <[EMAIL PROTECTED]> wrote:

Hi,



I am trying to get the hang of the tree2 component by means of modifying and
fiddling with the MyFaces examples.



Basically, I want to be able to click on a document node (I am using the
TreeBacker class as my backing bean class) and display some information
about the selected node. Everything seems to work just fine as long as I am
not trying to display the selected node's identifier. When I do that, no
data seems to be passed in the request.



Here is what I take to be the relevant piece of code:



----



       <f:facet name="document">

           <h:panelGroup>

               <h:commandLink immediate="true"
action="#{selectedNode.retrieveParameterValue}"
styleClass="#{t.nodeSelected ? 'documentSelected':'document'}"
actionListener="#{t.setNodeSelected}">

                   <t:graphicImage value="/images/document.png"
border="0"/>

                   <h:outputText value="#{node.description}"/>

                   <f:param name="nodeInfo" value="#{node.identifier}"/>

               </h:commandLink>

           </h:panelGroup>

       </f:facet>

   </t:tree2>

   <br/>

<h:outputText value="#{selectedNode.value}"/>



----



When the user clicks the description text of a document node, the text gets
bold, just as in the MyFaces set of tree2 examples. The
retrieveParameterValue is executed (please, see below for the source of the
backing bean) and the value of the request parameter ("nodeInfo") is passed
on to the value of the outputText statement in the jsp.



public class NodeHandler

{

   private String value;



   public NodeHandler()

   {



   }



   public String getValue()

   {

       return value;

   }



   public void setValue(String value)

   {

       this.value = value;

   }



   public void retrieveParameterValue()

   {

       value =
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("nodeInfo").toString();

   }



}





Everything works as I expect it to (admittedly, I may expect the wrong
thing) as long as I am not trying to pass the node.identifier value:



<f:param name="nodeInfo" value="#{node.identifier}"/>



As far as I can tell, the "nodeInfo" request parameter is part of the http
request but without a value.



If I use:

<f:param name="nodeInfo" value="#{node.description}"/>,

<f:param name="nodeInfo" value="#{node.type}"/> or

<f:param name="nodeInfo" value="#{node.leaf}"/>



It seems to work just fine (in the sense that I get the data I am asking
for).



Any hints or suggestions are greatly appreciated.



Regards,

Andreas Lund






Reply via email to