3 Replies Latest reply on Jun 13, 2007 8:20 AM by sergeysmirnov

    dynamic dialog launch

    proxima84

      Hello.
      I have a problem with a dynamic dialog launch in a new window. I use Tdinidad and plug "a4f:support" to a "tr:commandButton". When I click button dialog appears, but I got an error message inside previous page.
      First jsp:

      <?xml version='1.0' encoding='windows-1251'?>
      <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:tr="http://myfaces.apache.org/trinidad"
       xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
       <f:loadBundle basename="ru.csbi.webapp.resources.UIResources" var="res" />
      
       <jsp:directive.page contentType="text/html;charset=windows-1251" />
       <f:view>
       <tr:document>
       <h:form id="form1">
       <tr:outputText value="First" inlineStyle="font-size:18px;font-weight:bold;"></tr:outputText>
       <tr:commandButton text="next" id="next">
       <a4j:support event="onclick" action="#{employee.update}" disableDefault="true" ></a4j:support>
       </tr:commandButton>
       </h:form>
       </tr:document>
       </f:view>
      </jsp:root>
      


      dialog jsp:
      <?xml version='1.0' encoding='windows-1251'?>
      <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:tr="http://myfaces.apache.org/trinidad"
       xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
       <f:loadBundle basename="ru.csbi.webapp.resources.UIResources" var="res" />
       <jsp:directive.page contentType="text/html;charset=windows-1251" />
       <f:view>
       <tr:document>
       <h:form id="form1">
       <tr:outputText value="Second" inlineStyle="font-size:18px;font-weight:bold;"></tr:outputText>
       </h:form>
       </tr:document>
       </f:view>
      </jsp:root>
      


      MyBean:
      
      import javax.faces.application.ViewHandler;
      import javax.faces.component.UIViewRoot;
      
      import javax.faces.context.FacesContext;
      
      import org.apache.myfaces.trinidad.component.core.nav.CoreCommandButton;
      import org.apache.myfaces.trinidad.context.RequestContext;
      
      public class Employee
      {
      
       public Employee()
       {
       }
       public void update() {
       FacesContext context = FacesContext.getCurrentInstance();
       ViewHandler viewHandler = context.getApplication().getViewHandler();
       UIViewRoot dialog = viewHandler.createView(context, "/second.jsp");
       HashMap properties = new HashMap();
       CoreCommandButton bt=(CoreCommandButton)context.getViewRoot().findComponent("form1:next");
       properties.put("isDialog", true);
       properties.put("source",bt );
       HashMap windowProperties = new HashMap();
       windowProperties.put("width", "800");
       windowProperties.put("height", "600");
       RequestContext requestContext = RequestContext.getCurrentInstance();
       requestContext.launchDialog(dialog, properties, bt, true, windowProperties);
      
      }
      }
      


      How can I solve that problem?
      Can anybody help me?

      Tat'yana

        • 1. Re: dynamic dialog launch
          ilya_shaikovsky

          use a4j:command component insitead..

          • 2. Re: dynamic dialog launch
            proxima84

            I've replaced this code

            <tr:commandButton text="next" id="next">
             <a4j:support event="onclick"
             requestDelay="300" action="#{employee.update}" disableDefault="true" ignoreDupResponses="true">
            </a4j:support>
            </tr:commandButton>
            

            by this
            <a4j:commandButton value="next" id="next" action="#{employee.update}">
            </a4j:commandButton>
            


            but error message still appears.

            • 3. Re: dynamic dialog launch

              1. the action method is a method that has no parameters and return String. So, your #{employee.update} has a wrong signature

              2. Ajax4jsf is not partial updating of the same page. It looks for me that you try to use it improperly in this particular example.