我正在使用JSF Mojarra 2.0.3实现以及Apache Trinidad 2.0.0 beta框架,以便我可以使用树组件。JSF特立尼达树组件不扩展
我跟着developers guide关于树组件,以及Oracle ADF tutorial,但我没有成功地复制Oracle示例。
树组件获取呈现,但它不展开/折叠。我只能看到根元素。
玩apache demo tree component,我注意到该页面没有重新加载。它似乎是阿贾克斯管理。
所以我认为我的问题是我有我的树组件到表单JSF标记。无论如何,如果我不把树组件放到h:form标签中,树组件不会被渲染。
将树组件嵌入到表单中后,我也注意到当我尝试从树中展开节点时,整个页面都会重新加载。这可以解释为什么树没有扩大。
任何人都有关于特立尼达树组件的线索?
顺便说一句,树组件是我使用的唯一的Trinidad组件。我不知道它是否与JSF Mojarra的实现默认组件不兼容。
仍然不起作用。用根元素呈现的树,但用鼠标点击时不会展开。现在只有一个和标签在最终的html文档中。在这里我XHTML的:
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>
所引用:
<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:
公共类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;
}
}
使用这种情况的另一个问题,我应该在哪里指定我的css文件?我还没有找到文档标签的任何属性。我如何访问和特立尼达生成的标签?
你能告诉我你是如何指定你的身体和html标签?我已将它们指定为“
和”。这可能是问题吗?关键是,遵循不同的JSF教程,我总是看到他们通常使用这种标签,而不是“嗨,我编辑了我的答案。这是我的页面的整个代码。特立尼达的标签生成。有关tr:文档,请参阅Trinidad标签文档。是的,这可能是你的问题。尝试一个仅包含特立尼达东西的简单页面,看看你的树是否像预期的那样工作。 –
lkdg
2011-04-27 12:36:06
我不太了解你的例子。我认为这不是一个标准的xhtml网页,是吗?我在哪里可以定义我的CSS和JavaScript资源?我没有看到此任务的任何适当的文档属性。 – David 2011-04-27 15:36:34