6 Replies Latest reply on Jan 19, 2012 7:08 AM by Matthias Hinderkott

    How can i do Userquestions while processing Java code..

    Matthias Hinderkott Newbie

      Hello Everyone,

       

      i have a problem...I want ask the user about something and act diferently..  What is the common way to do such things ? I think surely im not the first person how need to do this..

      My first try was to create a UIPopupPanel.. but i have biiiiig problems because i dont know how to create buttons on that Panel and how to link their events to a java method(in fact i have  no exp working with UIXxxX classes )..

       

      Can someone give me common ways to handle userquestions..? 

       

      Greetings from Germany

       

      Matthias H.

        • 1. Re: How can i do Userquestions while processing Java code..
          Vitaliy Pavlov Novice

          Hi, Matthias

           

          You may using next code

           

          <h:form>

                   <rich:popupPanel id="popup" domElementAttachment="form" modal="true"

                                    onmaskclick="#{rich:component('popup')}.hide()"

                                    resizeable="true">

                       <f:facet name="header">

                           <h:outputText value="header"/>

                           <f:facet name="controls">

                               <h:outputLink value="#"

                                             onclick="#{rich:component('popup')}.hide(); return false;">

                                   X

                               </h:outputLink>

                           </f:facet>

                       </f:facet>

            

                      <br/><br/>

                        <h:outputText value="You question ..."/>

                       <br/><br/>

            

                      <h:panelGrid columns="2">

           

                          <a4j:commandButton

                                   actionListener="#{myBeen.doSomething}"

                                   onclick="#{rich:component('popup')}.hide(); return true;"

                                   value="OK"/>

            

                          <h:commandButton

                                   onclick="#{rich:component('popup')}.hide(); return false;"

                                   value="Cancel"/>

                       </h:panelGrid>

           

                    </rich:popupPanel>

               </h:form>

           

          Regards, Vitaliy

          • 2. Re: How can i do Userquestions while processing Java code..
            Matthias Hinderkott Newbie

            Hello Vitaliy,

            thanks for the fast answer.

             

            How can i make the Popup open out of a java method ?

             

            Regards, Matthias

            • 3. Re: How can i do Userquestions while processing Java code..
              Bernard Labno Master

              YOu can't. You must write your controller (JSF backing bean) the right way.

              i.e.

              {code:java}public class Bean {

                  private Object attributeA;

                  //getters and setters

               

                  public String doStuff() {

                      if(this.attributeA==null) {

                          return "dataNeeded";

                      }

                      //...other checks

                      //final logic

                  }

              }{code:java}

               

              {code:xml}<rich:popupPanel id="popup" .../>

              <a4j:outputPanel ajaxRendered="true">

                  <h:panelGroup  rendered="#{empty bean.attributeA}">/**JavaScript showing panel*/</h:panelGroup>

              </a4j:outputPanel>{code:xml}

              • 4. Re: How can i do Userquestions while processing Java code..
                Matthias Hinderkott Newbie

                hmm ok

                 

                Thats my code at the moment:

                 

                <a4j:outputPanel ajaxRendered="true" >

                <h:panelGroup  rendered="#{myController.showit}">

                               

                            //Need a way to execute Javascript..

                </h:panelGroup>

                </a4j:outputPanel>

                       

                            <rich:popupPanel id="popup" modal="true" resizeable="true"   >

                            <f:facet name="controls">

                                <h:outputLink onclick="#{rich:component('popup')}.hide()">X</h:outputLink>

                            </f:facet>

                               TEXTEXTTEXTTEXTEXTTEXTTEXTEXTTEXT<br/>

                               TEXTEXTTEXTTEXTEXTTEXTTEXTEXTTEXT ?

                                <h:panelGrid columns="2">

                                    <a4j:commandButton value="Ja" onclick="#{rich:component('popup')}.hide()">

                                        <a4j:ajax event="click" listener="#{myController.doSthForYes()}"/>

                                    </a4j:commandButton>

                                   

                                    <a4j:commandButton value="Nein" onclick="#{rich:component('popup')}.hide()" >

                                        <a4j:ajax event="click" listener="#{myController.doSthForNo()}"/>

                                    </a4j:commandButton>

                                </h:panelGrid>

                            </rich:popupPanel>

                 

                 

                How can i execute Javascript ?

                is there an onrendered, that i can #{rich:component('popup')}.show() or what is the way of showing the panel  ?

                 

                in the methods doSthForNo and doSthForYes i can place my logic ? and in the end set the showit to false that no more popups will come out ?

                 

                 

                Regarts Matthias

                • 5. Re: How can i do Userquestions while processing Java code..
                  Bernard Labno Master

                  substitute "//Need a way to execute Javascript.."

                  with

                  <script>#{rich:component('popup')}.show();</script>

                   

                  Yes, doSthForNo and doSthForYes are the right place for logic, and yes, change value of showit to false if you don't want to show the modal panel.

                  • 6. Re: How can i do Userquestions while processing Java code..
                    Matthias Hinderkott Newbie

                    Great works thanks a lot

                     

                    Best Regards Matthias.