2016-02-23 5 views
1

Я новичок в RichFaces, и я пытаюсь вызвать popupPanel из другого xhtml. Я использую a4j: commnandLink и a4j: commandButton для вызова того же всплывающего окна. Один для редактирования пользователя (передача параметров), а другой - создание нового. Зависимости: RichFaces 4.3.5.Final, JSF 2.1.9 EL 2,2Как вызвать общий ресурс: popupPanel из другого xhtml

Здесь главная страница называется 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 в том же каталоге и в Аноф и не работает. Я также попытался изменить метод редактирования в bean-компоненте, чтобы вернуть «edit» и работать в кнопке commandLink, но только если преобразовать popupPanel в rich: panel

Заранее спасибо.

+0

Вы пытаетесь поставить ВКЛЮЧАЕТ вне формы? – 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()" />