2016-02-23 43 views
1

我是RichFaces的新手,我试图从其他xhtml调用popupPanel。我使用a4j:commnandLink和a4j:commandButton来调用相同的弹出窗口。一个用于编辑用户(传递参数),另一个创建一个新的。 依赖关系:RichFaces的4.3.5.Final,JSF 2.1.9 EL 2.2如何从其他xhtml调用共享的rich:popupPanel

这里被称为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> 

而且userAction豆..

@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); 
     } 
    } 
} 

我试图位于edit.xhtml在同一目录和anoth呃并且不起作用。我也尝试修改bean中的编辑方法以返回“编辑”并在commandLink按钮中工作,但只有在变换富文本中的popupPanel时才有效:面板

在此先感谢。

+0

你尝试把includ形式之外? – user3489875

回答

0

你已经调用

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

但是这条线的位置是错误的。把它形式的外list.xhtml,如:

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

:因为现在它是内部形状,你嵌套在弹出,这不是由JSF支持形式。

你可以调用弹出就像是在同一个文件:

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