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

    dynamic dialog launch

    Tat'yana Demidova Newbie

      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