title: How can I get popup window using commandButton in Trinidad?
body: <p>How can I get popup window using <code>commandButton</code> in Trinidad? </p>
  
  <p>My problem is that by clicking on <code>Add</code> button from <code>dialogdemo.jspx</code>, not any popup window or dialog box is opened.</p>
  
  <p>This is <code>dialogdemo.jspx</code> file:</p>
  
  <pre><code>&lt;jsp:root 
      xmlns:jsp="http://java.sun.com/JSP/Page" 
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:tr="http://myfaces.apache.org/trinidad" 
      version="1.2"&gt;
      &lt;jsp:directive.page contentType="text/html;charset=utf-8" /&gt;
      &lt;f:view&gt;
          &lt;tr:document title="Dialog Demo"&gt;
              &lt;tr:form&gt;
                  &lt;!--
                      The field for the value; we point partialTriggers at the 
                      button to ensure it gets redrawn when we return
                  --&gt;
                  &lt;tr:inputText label="Pick a number:" partialTriggers="buttonId"
                      value="#{launchDialog.input}" /&gt;
                  &lt;!--
                      The button for launching the dialog: we've also configured 
                      the width and height of that window
                  --&gt;
                  &lt;tr:commandButton text="Add" action="dialog:chooseInteger" 
                      id="buttonId" windowWidth="300" windowHeight="200" 
                      partialSubmit="true" useWindow="true"
                      returnListener="#{launchDialog.returned}" /&gt;
              &lt;/tr:form&gt;
          &lt;/tr:document&gt;
      &lt;/f:view&gt;
  &lt;/jsp:root&gt;
  </code></pre>
  
  <p>Here is the associated managed bean <code>LaunchDialogBean.java</code>:</p>
  
  <pre><code>package jsfpkg;
  
  import org.apache.myfaces.trinidad.component.UIXInput;
  import org.apache.myfaces.trinidad.event.ReturnEvent;
  
  public class LaunchDialogBean {
      private UIXInput _input;
  
      public UIXInput getInput() {
          return _input;
      }
  
      public void setInput(UIXInput input) {
          _input = input;
      }
  
      public void returned(ReturnEvent event) {
          if (event.getReturnValue() != null) {
              getInput().setSubmittedValue(null);
              getInput().setValue(event.getReturnValue());
          }
      }
  
  }
  </code></pre>
  
  <p>Here is the popup file <code>Popup.jspx</code>:</p>
  
  <pre><code>&lt;jsp:root 
      xmlns:jsp="http://java.sun.com/JSP/Page" 
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:trh="http://myfaces.apache.org/trinidad/html"
      xmlns:tr="http://myfaces.apache.org/trinidad"
      version="2.0"&gt;
      &lt;jsp:directive.page contentType="text/html;charset=utf-8" /&gt;
      &lt;f:view&gt;
          &lt;tr:document title="Add dialog"&gt;
              &lt;tr:form&gt;
                  &lt;!-- Two input fields --&gt;
                  &lt;tr:panelForm&gt;
                      &lt;tr:inputText label="Number 1:" value="#{chooseInteger.value1}"
                          required="true" /&gt;
                      &lt;tr:inputText label="Number 2:" value="#{chooseInteger.value2}"
                          required="true" /&gt;
                  &lt;/tr:panelForm&gt;
  
                  &lt;!-- Two buttons --&gt;
                  &lt;tr:panelGroup layout="horizontal"&gt;
                      &lt;tr:commandButton text="Submit" action="#{chooseInteger.select}" /&gt;
                      &lt;tr:commandButton text="Cancel" immediate="true"
                          action="#{chooseInteger.cancel}" /&gt;
                  &lt;/tr:panelGroup&gt;
              &lt;/tr:form&gt;
          &lt;/tr:document&gt;
      &lt;/f:view&gt;
  &lt;/jsp:root&gt;
  </code></pre>
  
  <p>For that I have written the bean <code>ChooseIntegerBean.java</code></p>
  
  <pre><code>package jsfpkg;
  
  import org.apache.myfaces.trinidad.context.RequestContext;
  
  public class ChooseIntegerBean {
  
      private Integer _value1;
      private Integer _value2;
  
      public Integer getValue1() {
          return _value1;
      }
  
      public void setValue1(Integer value1) {
          _value1 = value1;
      }
  
      public Integer getValue2() {
          return _value2;
      }
  
      public void setValue2(Integer value2) {
          _value2 = value2;
      }
  
      public String cancel() {
          RequestContext.getCurrentInstance().returnFromDialog(null, null);
          return null;
      }
  
      public String select() {
          Integer value = new Integer(getValue1().intValue() + getValue2().intValue());
          RequestContext.getCurrentInstance().returnFromDialog(value, null);
          return null;
      }
  
  }
  </code></pre>
  
  <p>Here is my <code>faces-config.xml</code>:</p>
  
  <pre><code>&lt;managed-bean&gt;
      &lt;managed-bean-name&gt;chooseInteger&lt;/managed-bean-name&gt;
      &lt;managed-bean-class&gt;jsfpkg.ChooseIntegerBean&lt;/managed-bean-class&gt;
      &lt;managed-bean-scope&gt;request&lt;/managed-bean-scope&gt;
  &lt;/managed-bean&gt;
  
  &lt;managed-bean&gt;
      &lt;managed-bean-name&gt;launchDialog&lt;/managed-bean-name&gt;
      &lt;managed-bean-class&gt;jsfpkg.LaunchDialogBean&lt;/managed-bean-class&gt;
      &lt;managed-bean-scope&gt;
          request
      &lt;/managed-bean-scope&gt;
  &lt;/managed-bean&gt;
  
  &lt;navigation-rule&gt;
      &lt;from-view-id&gt;/dialogdemo.jspx&lt;/from-view-id&gt;
      &lt;navigation-case&gt;
          &lt;from-outcome&gt;dialog:chooseInteger&lt;/from-outcome&gt;
          &lt;to-view-id&gt;/dialogbox.jspx&lt;/to-view-id&gt;
      &lt;/navigation-case&gt;
  &lt;/navigation-rule&gt;
  </code></pre>