0

PrimeFaces 4.0 で Dialog Framework を使用しようとしていますが、次のページがあります。

index.xhtml

...
<p:commandButton value="Add Group" actionListener="#{userGroupBacking.showAddGroup}" styleClass="header-button ui-priority-primary" update="groupTable" >
    <p:ajax event="dialogReturn" listener="#{userGroupBacking.addGroupHandler}" />
</p:commandButton>
...

add.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:h="http://java.sun.com/jsf/html" 
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:p="http://primefaces.org/ui">

<h:head>
    <title>Add Group</title>
    <h:outputStylesheet library="css" name="style.css" />
</h:head>

<h:body>

    <h:form id="addGroupForm">
        <p:messages autoUpdate="true" />
        <h:panelGrid columns="2" cellspacing="10" width="300">  
            <h:outputLabel for="name" value="Group Name" />  
            <p:inputText id="name" value="#{userGroupBacking.newGroup}" required="true" requiredMessage="Group Name is Required" />  

            <h:panelGroup></h:panelGroup>
            <h:panelGroup>
                <p:commandButton value="Add" styleClass="ui-priority-primary" actionListener="#{userGroupBacking.addGroup}" />
                <p:commandButton value="Cancel" actionListener="#{userGroupBacking.cancelAddGroup}" immediate="true" />
            </h:panelGroup>
        </h:panelGrid> 
    </h:form>

</h:body>
</html>

UserGroupBacking.java

@ManagedBean(name="userGroupBacking")
@ViewScoped
public class UserGroupBacking {

    private String newGroup;



    /*#####################################################################################
     * Main Methods
     ######################################################################################*/


    /**
     * Loads the groups/add.xhtml dialog
     */
    public void showAddGroup() {
        Map<String, Object> options = new HashMap<String, Object>();
        options.put("modal", true);
        options.put("width", 350);
        options.put("contentWidth", 300);
        RequestContext.getCurrentInstance().openDialog("add", options, null);
    }

    public void addGroup() {
        RequestContext.getCurrentInstance().closeDialog(null);
    }

    public void cancelAddGroup() {
        RequestContext.getCurrentInstance().closeDialog(null);
    }

    public void addGroupHandler() {
        System.out.println("newGroup = "+newGroup);
    }

    /*#####################################################################################
     * Getters/Setters
     ######################################################################################*/

    public String getNewGroup() {
        return newGroup;
    }
    public void setNewGroup(String newGroup) {
        this.newGroup = newGroup;
    }

}

問題はaddGroupHandler、newGroup が常に null を出力することです。私のダイアログから設定すべきではありませんか?

4

0 に答える 0