You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Nebinger, David" <dn...@tbbgl.com> on 2007/05/14 19:21:56 UTC

T:tree + facelets + portlets = not working?

I've got what I think is a pretty simple xhtml page, more or less the
intent is to have an explorer type view with a tree on the left and a
display area on the right (the display area changes depending upon the
item that gets chosen from the tree).

The items in the tree have a simple numeric identifier starting with
zero (but stored in the node as a String).

In the page below, when I click on an item in the tree the submit takes
place but my nodeSelected method never gets called.  In the display area
I hacked up a sample link to ensure that things were kosher as far as
the link is concerned, and it works.  I viewed the source of the
generated page, and the javascript is a mirror copy of what is in the
tree vs. in the link directly (except for the different element id).

I tried debugging through the code but could not find out why the action
method isn't getting called, and there are no exceptions or warnings or
anything in the log file to help me resolve the problem.

Can anyone offer some clues as to how I might get this to work?

Thanks!

viewTree.xhtml:

<f:view xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:c="http://java.sun.com/jstl/core"
  xmlns:t="http://myfaces.apache.org/tomahawk">

<h:form >
  <h:panelGrid columns="2" columnClasses="tbb-list-col-left">
    <h:panelGroup>
      <!-- *** TREE COMPONENT *** -->
      <t:tree2 id="treeComp" value="#{navTree.tree}"
clientSideToggle="true" varNodeToggler="t" var="node"
imageLocation="/images" binding="#{navTree.htmlTree}" >
        <f:facet name="category">
          <h:panelGrid id="a" columns="2" cellpadding="0"
cellspacing="0">
            <t:graphicImage value="/images/yellow-folder-open.png"
rendered="#{t.nodeExpanded}" />
            <t:graphicImage value="/images/yellow-folder-closed.png"
rendered="#{!t.nodeExpanded}" />
            <h:outputText value="#{node.description}"
styleClass="nodeFolder" />
          </h:panelGrid>
        </f:facet>
        <f:facet name="item">
          <h:panelGroup>
            <h:commandLink styleClass="#{t.nodeSelected ?
'documentSelected':'document'}" action="#{navTree.nodeSelected}"
immediate="true">
              <h:panelGrid id="b" columns="2" cellpadding="0"
cellspacing="0">
                <t:graphicImage value="/images/document.png" />
                <h:outputText value="#{node.description}" />
              </h:panelGrid>
              <f:param name="docNum" value="#{node.identifier}" />
            </h:commandLink>
          </h:panelGroup>
        </f:facet>
      </t:tree2>
      <!-- *** END OF TREE COMPONENT *** -->
    </h:panelGroup>
    <h:panelGrid columns="1" cellpadding="10">
      <h:outputText value="Display Area" />
      <h:commandLink actionListener="#{navTree.nodeSelected}"
value="Test Link">
        <f:param name="docNum" value="0" />
      </h:commandLink>
    </h:panelGrid>
  </h:panelGrid>
  <h:messages />
</h:form>
</f:view>

The backing bean has a pretty simple nodeSelected() method:

	public String nodeSelected() {
		logger.info("*** In nodeSelected ***");

		FacesContext ctx = FacesContext.getCurrentInstance();
		Map map =
ctx.getExternalContext().getRequestParameterMap();

		String nodeId = (String) map.get("docNum");

		if ((nodeId == null) || (nodeId.trim().length() < 1)) {
			logger.error("Invalid node id from incoming
command link.");
		} else {
			logger.info("Have selected node id with value ["
+ nodeId + "].");

			if ("0".equals(nodeId)) {
				return NavigationKeys.NAV_VIEW_ROLES;
			}
			if ("1".equals(nodeId)) {
				return NavigationKeys.NAV_VIEW_GROUPS;
			}
			if ("2".equals(nodeId)) {
				return NavigationKeys.NAV_VIEW_USERS;
			}
			if ("3".equals(nodeId)) {
				return
NavigationKeys.NAV_VIEW_INACTIVE_USERS;
			}
		}

		return null;
	}