0
votes

I'm using JSF Mojarra 2.0.3 implementation along with Apache Trinidad 2.0.0 beta framework, so that I can use tree component.

I've followed developers guide regarding tree component, as well as the Oracle ADF tutorial, but I haven't succeded in reproducing the Oracle example.

Tree component gets rendered, but it doesn't expand/collapse. I only can see the root elements.

Playing with the apache demo tree component, I've noticed that the page is not reloaded. It seems to be ajax managed.

So I think my problem is that I have my tree component into a form JSF tag. Anyway, if I don't place the tree component into a h:form tag, the tree component is not rendered.

Having the tree component embeded into a form, I have also noticed that when I try to expand a node from the tree, the whole page reloads. It may explain why the tree is not expanding.

Anyone has a clue about Trinidad tree component?

By the way, tree component is the only Trinidad component I'm using. I don't know if it is some sort of incompatibility with JSF Mojarra's implementation default components.

Still doesn't work. Tree rendered with root elements, but they don't expand when clicking with mouse. Now only one and tags in the final html document. Here my xhtml's:

header.xhtml:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets">

    <div id="header" class="header">
        <div id="header_title">
            <p>#{msg.app_title}</p>
        </div>
        <div id="clear"/>
    </div>

</ui:composition>

footer.xhtml:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets">

            <div id="footer" class="footer">#{msg.app_footer}</div>

</ui:composition>

template.xhtml:

<tr:document xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:tr="http://myfaces.apache.org/trinidad"
      title="#{msg.app_title}">

    <div id="header">
        <ui:include src="/WEB-INF/templates/header.xhtml"/>
    </div>

    <center>
    <div id="content">
      <ui:insert name="content">
      </ui:insert>
    </div>
    </center>

    <div id="footer">
        <ui:include src="/WEB-INF/templates/footer.xhtml"/>
    </div>
</tr:document>

login.xhtml:

<ui:composition template="/WEB-INF/templates/template.xhtml"
                        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:tr="http://myfaces.apache.org/trinidad">

    <ui:define name="content">
        <tr:form id="login_form">
            <h:panelGrid columns="3">
                <h:outputText value="#{msg.username}"></h:outputText>
                <h:inputText id="username" value="#{loginBean.username}" required="true"/>
                <h:message for="username" class="error_message"/>

                <h:outputText value="#{msg.password}"></h:outputText>
                <h:inputSecret id="password" value="#{loginBean.password}" required="true">
                    <f:validator validatorId="checkUserValidator"/>
                    <f:attribute name="usernameId" value="username"/>
                </h:inputSecret>

                <h:message for="password" class="error_message"/>
            </h:panelGrid>
           <h:commandButton value="#{msg.login}" action="#{loginBean.checkUser}"/>

           <tr:panelBox background="transparent">        
                <tr:tree var="menu" value="#{testTree.tree}">
                    <f:facet name="nodeStamp">
                        <tr:goLink text="#{menu.name}"/>
                    </f:facet>
                </tr:tree>
              </tr:panelBox>

        </tr:form>
        <h:outputLink value="/MyApp/faces/newAccount.xhtml">
            <h:outputText value="#{msg.create_account}"></h:outputText>
        </h:outputLink>
    </ui:define>
</ui:composition>

TestTree.java:

public class TestTree{

private TreeModel tree;


public TestTree(){

    Person john = new Person("John Smith");
    Person kim = new Person("Kim Smith");
    Person tom = new Person("Tom Smith");
    Person ira = new Person("Ira Wickrememsinghe");
    Person mallika = new Person("Mallika Wickremesinghe");

    john.getKids().add(kim);
    john.getKids().add(tom);
    ira.getKids().add(mallika);

    // create the list of root nodes:
    List people = new ArrayList();
    people.add(john);
    people.add(ira);

    tree = new ChildPropertyTreeModel(people, "kids");
}

public TreeModel getTree(){
    return tree;
}

public void setTree(TreeModel tree){
    this.tree = tree;
}

}


Another question by using this case, where should I specify my css file? I haven't found any attribute for document tag. How can I access and tags generated by Trinidad?

1

1 Answers

0
votes

I am using the trinidad tree component (trinidad 1.2.14) on jsf1.2 without any problems. I don't know how trinidad works together with the mojarra implementation.

My site look like this, as described in Tag Documentation :

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://myfaces.apache.org/trinidad" prefix="tr" %>
<%@ taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>

<f:view>

<tr:document>
<tr:form id="frmMain">
  <tr:panelBox background="transparent">        
    <tr:tree var="menu" value="#{myBean.model}">
        <f:facet name="nodeStamp">
            <tr:goLink 
                text="#{menu.label}" 
                destination="#{menu.address}"
                targetFrame="Data"/>
        </f:facet>
    </tr:tree>
  </tr:panelBox>
</tr:form>
</tr:document>
</f:view>

Probably this helps you to narrow the problem.