Jsf 2 如何从其他xhtml调用共享富:popupPanel

Jsf 2 如何从其他xhtml调用共享富:popupPanel,jsf-2,richfaces,ajax4jsf,Jsf 2,Richfaces,Ajax4jsf,我是RichFaces的新手,我正在尝试从其他xhtml调用popupPanel。我使用a4j:commnandLink和a4j:commandButton调用相同的弹出窗口。一个用于编辑用户(传递参数),另一个用于创建新用户。 依赖项:richfaces 4.3.5.Final,jsf 2.1.9 EL 2.2 这是名为list.xhtml的主页 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-

我是RichFaces的新手,我正在尝试从其他xhtml调用popupPanel。我使用a4j:commnandLink和a4j:commandButton调用相同的弹出窗口。一个用于编辑用户(传递参数),另一个用于创建新用户。 依赖项:richfaces 4.3.5.Final,jsf 2.1.9 EL 2.2

这是名为list.xhtml的主页

  <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<html 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:rich="http://richfaces.org/rich"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:xf="http://www.aqualogy.net/xf/components/xf">
<h:form id="searchFilter">
    <h:panelGrid columns="4">
        <h:outputLabel for="searchFilter_username" value="usuario" />
        <h:inputText id="searchFilter_username"
            value="#{usersAction.filter.username}" label="nombre usuario" />
    </h:panelGrid>
    <h:commandButton action="#{usersAction.findUsers}" styleClass="search"
        value="buscar" />
</h:form>
<h:form>
    <rich:extendedDataTable id="searchResult" var="user"
        value="#{usersAction.users.data}"
        rows="#{requestConfiguration.itemsPerPage}" sortMode="single"
        selectionMode="none" rowClasses="odd-row, even-row"
        styleClass="stable" noDataLabel="no result Found">
        <rich:column>
            <f:facet name="header">
                <h:outputText value="Actions" />
            </f:facet>
            <a4j:commandLink id="link1" action="#{usersAction.edit(user)}">
                <f:setPropertyActionListener value="#{user}"
                    target="#{usersAction.users.currentItem}" />
                <h:graphicImage
                    value="#{xf:themeResource('images/buttons/update.png')}"
                    style="border:0" />
                <rich:tooltip
                    value="#{webComponentUIMessages['table.buttons.modify']}" />
            </a4j:commandLink>
        </rich:column>
        <rich:column sortBy="#{user.username}" width="150px">
            <f:facet name="header">
                <h:outputText value="username" />
            </f:facet>
            <h:outputText value="#{user.username}" />
        </rich:column>
        <f:facet name="footer">
            <xf:tableFooter data="#{usersAction.users.data}" />
        </f:facet>
    </rich:extendedDataTable>
    <h:commandButton id="button1" action="edit" styleClass="add"
        value="Add1">
    </h:commandButton>
    <a4j:commandButton id="button2" action="#{usersAction.create}"
        styleClass="add" value="Add2"
        render=":editPanel_messages :editPanel_form:content"
        oncomplete="#{rich:component('editPanel4')}.show();" />
    <ui:include src="edit4.xhtml"></ui:include>
</h:form>
</html>

这里是edit.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<ui:composition 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:rich="http://richfaces.org/rich"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:xf="http://xf/components/xf">
    <rich:popupPanel id="editPanel4"
        header="#{webComponentUIMessages['edit.detail']}">
        <f:facet name="header">
            <h:outputText value="PopUp Panel" />
        </f:facet>
        <f:facet name="controls">
            <h:panelGroup>
                <h:graphicImage
                    value="#{xf:themeResource('images/components/popupPanel/close.png')}"
                    styleClass="hidelink">
                    <h:outputLink
                        target="#{rich:component('popup')}.hide();return false;" value="#">
                            x
                            </h:outputLink>
                </h:graphicImage>
            </h:panelGroup>
        </f:facet>
        <xf:messages id="editPanel_messages" />
        <h:form id="editPanel_form">
            <h:panelGroup id="content" layout="block">
                <h:outputLabel for="userName"
                    value="#{securityWebMessages['user.username']}"
                    style="display: block; width:161px" />
                <h:inputText id="userName" maxlength="50"
                    label="#{securityWebMessages['user.username']}" value="usuario"
                    required="true" />
            </h:panelGroup>
        </h:form>
    </rich:popupPanel>
</ui:composition>

x
和用户操作bean

@Action("usersAction") @Lazy
@Scope(WebApplicationContext.SCOPE_SESSION)
public class UsersAction {

private DataTableHelper<User> users = new DataTableHelper<User>();


    @PostConstruct
    public void init() {
        filter = userStore.newUser();
        ldapUserFilter=new net.aqualogy.xf.component.ldap.model.User();
        users.setData(new GenericDataModel<User>() {
....
}

public void create() {
        this.ldapUser = null;
        users.setCurrentItem(userStore.newUser());
    }

public void edit(User user) {
        this.ldapUser = null;
        if (newUsers.getCurrentItem() != null && user == null) {
            users.setCurrentItem(newUsers.getCurrentItem());
        } else {
            users.setCurrentItem(user);
        }
    }
}
@Action(“usersAction”)@Lazy
@作用域(WebApplicationContext.Scope\u会话)
公共类用户权限{
私有DataTableHelper用户=新DataTableHelper();
@施工后
公共void init(){
filter=userStore.newUser();
ldapUserFilter=new net.aqualogy.xf.component.ldap.model.User();
users.setData(新的GenericDataModel(){
....
}
公共void create(){
this.ldapUser=null;
users.setCurrentItem(userStore.newUser());
}
公共作废编辑(用户){
this.ldapUser=null;
if(newUsers.getCurrentItem()!=null&&user==null){
users.setCurrentItem(newUsers.getCurrentItem());
}否则{
users.setCurrentItem(用户);
}
}
}
我试图将edit.xhtml定位在同一个目录和另一个目录中,但不起作用。我还试图修改bean中的edit方法以返回“edit”,并在commandLink按钮中起作用,但只有在rich:面板中转换popupanel时才起作用

提前谢谢。

您已经打过电话了

<ui:include src="edit4.xhtml"></ui:include>

但此行的位置是错误的。请将其放在list.xhtml的表单之外,如:

<ui:include src="edit.xhtml" />

注意:因为现在它在表单内部,您在弹出窗口中有嵌套表单,这是JSF不支持的

您可以调用popup,就像它在同一个文件中一样:

<a4j:commandButton value="Edit" immediate="true"
    onclick="#{rich:component('editPanel4')}.show()" />

您已经打过电话了

<ui:include src="edit4.xhtml"></ui:include>

但此行的位置是错误的。请将其放在list.xhtml的表单之外,如:

<ui:include src="edit.xhtml" />

注意:因为现在它在表单内部,您在弹出窗口中有嵌套表单,这是JSF不支持的

您可以调用popup,就像它在同一个文件中一样:

<a4j:commandButton value="Edit" immediate="true"
    onclick="#{rich:component('editPanel4')}.show()" />


您是否尝试将includ置于表单之外?是否尝试将includ置于表单之外?