OminiFaces的'o:methodParam'现在可以为我工作,如下所示。我怎样才能用另一种方式?我不知道我错过了什么。它可以与<h:commandButton>
和<a4j:jsFunction>
一起使用,而不使用Seam
,当使用Seam
时,它不适用于<a4j:jsFunction>
。Ominifaces EL字符串传递
发展Eviroment是 RichFaces 4. Seam 2.3 OminiFaces 1.2 JBoss 7.1.1
@Name("DataTableBacking")
public class DataTableBacking {
Department[] items = {new Department("AAA", "AAA"), new Department("BBB", "BBB"), new Department("CCC", "CCC")};
public Department[] getItems() {
return items;
}
public void action(Department action) {
System.out.println("Action called with:" + action.getName());
}
}
datatable.xhtml
<h:html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:richm="http://developmentTutorials.com/java">
<h:body>
<h:form>
<h1>Data Table</h1>
<rich:dataTable id="departmentTable" value="#{DataTableBacking.items}" var="dep" style="width:100%">
<rich:column style="width:100px;text-align:center;">
#{dep.name}
<richm:confirmLink actionBeanMethod="#{DataTableBacking.action(dep)}" render="departmentTable"/>
</rich:column>
</rich:dataTable>
</h:form>
</h:body>
</h:html>
在标记库,confirmation.xml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:o="http://omnifaces.org/ui"
xmlns:of="http://omnifaces.org/functions"
xmlns:ui="http://java.sun.com/jsf/facelets">
<o:methodParam name="methodParam" value="#{actionBeanMethod}" />
<a4j:commandLink value="delete" onclick="#{rich:component('confirmation')}.show();return false" />
<h:commandButton value="direct" action="#{methodParam}" />
<a4j:jsFunction name="submit" action="#{methodParam}" render="#{render}" />
<rich:popupPanel id="confirmation" width="250" height="150">
<f:facet name="header">Confirmation</f:facet>
<h:panelGrid>
<h:panelGrid columns="1">
<h:outputText value="Are you sure?" style="FONT-SIZE: large;" />
</h:panelGrid>
<h:panelGroup>
<input type="button" value="OK" onclick="#{rich:component('confirmation')}.hide(); submit(); return false" />
<input type="button" value="Cancel" onclick="#{rich:component('confirmation')}.hide(); return false" />
</h:panelGroup>
</h:panelGrid>
</rich:popupPanel>
</ui:composition>
确认,在视图范围内是'#{ManageDepartmentAction}',getDepartmentList()是纯粹的getter? – BalusC
'ManageDepartmentAction'是JBoss Seam的'Conversation'范围。 'getDepartmentList()'是一个纯粹的getter方法。 'departmentList'已经在bean的初始状态从数据库中检索出来(通过使用@Begin)'。 'getDepartmentList()'方法只返回'departmentList'。 – CycDemo
如果从JSF中将“@Named”(“@Name is typo?”)更改为@ManagedBean,会发生什么?请注意,有两个注释,在这种情况下,您需要javax.faces。 –