To answer my own question:
<f:facet name="document">
<h:panelGroup>
<h:commandLink immediate="true"
styleClass="#{t.nodeSelected ? 'documentSelected' : 'document'}"
actionListener="#{t.setNodeSelected}"
rendered="#{!t.nodeSelected}">
<h:graphicImage value="/images/document.png" border="0"/>
<h:outputText value="#{node.description}"/>
<f:param name="docNum" value="#{node.identifier}"/>
</h:commandLink>
</h:panelGroup>
</f:facet>
--
Rob
@objectsource.org
> I'm reading earlier posts on the selection listener and trying figure out
> what
> exactly
> is happening with it. I'm looking at
>
> <f:facet name="document">
> <h:panelGroup>
> <h:commandLink immediate="true" styleClass="document"
> actionListener="#{t.setNodeSelected}" rendered="#{!t.nodeSelected}">
> <h:graphicImage value="/images/document.png" border="0"/>
> <h:outputText value="#{node.description}"/>
> <f:param name="docNum" value="#{node.identifier}"/>
> </h:commandLink>
> <h:commandLink immediate="true" styleClass="documentSelected"
> actionListener="#{t.setNodeSelected}" rendered="#{t.nodeSelected}">
> <h:graphicImage value="/images/document.png" border="0"/>
> <h:outputText value="#{node.description}"/>
> <f:param name="docNum" value="#{node.identifier}"/>
> </h:commandLink>
> </h:panelGroup>
> </f:facet>
>
> This what I see is happening:
>
> When someone clicks the first command link, the 't' is just internally
> setting
> a
> variable so t.nodeSelected returns true. When page re-rendered the second
> link
> is
> displayed, which has a style that does something to indicate the node is
> selected.
>
> I'd like to continue being a lazy programmer and not have to type the content
> of my
> command link twice. Is there a way the above can be refactored so it only
> needs
> one
> command link? For instance in jstl I'd do:
>
> <c:if test="${t.nodeSelected}">
> <h:commandLink immediate="true" styleClass="documentSelected"
> actionListener="#{t.setNodeSelected}" rendered="#{t.nodeSelected}">
> </c:if>
> <c:if test="${!t.nodeSelected}">
> <h:commandLink immediate="true" styleClass="document"
> actionListener="#{t.setNodeSelected}" rendered="#{!t.nodeSelected}">
> </c:if>
> <h:graphicImage value="/images/document.png" border="0"/>
> <h:outputText value="#{node.description}"/>
> <f:param name="docNum" value="#{node.identifier}"/>
> </h:commandLink>
>
> I'm not clear on mixing jstl and jsf. Is this something works or is there a
> "JSF" way
> to do this?
> And what is the current tree way in
> "Of course you
> can always configure it to behave exactly the same as the current tree
> if that is your wish "
>
> of doing selection?