1 2 3 Previous Next 30 Replies Latest reply on Aug 1, 2007 5:26 PM by sergeysmirnov Go to original post
      • 15. Re: <a4j:commandButton> and <h:messages/>
        krasig

        The environment is:

        SUN JSF 1.2
        Facelets
        Ajax4jsf 1.1.1
        Richfaces 3.0.1


        • 16. Re: <a4j:commandButton> and <h:messages/>

          what if you replace a4j:commandButton with h:commandButton ?

          • 17. Re: <a4j:commandButton> and <h:messages/>
            krasig

            In this case - everything is OK.
            But this is not decision.

            • 18. Re: <a4j:commandButton> and <h:messages/>

              I am out of ideas. create the test application, zip it and attach to the the post in Jira.

              • 19. Re: <a4j:commandButton> and <h:messages/>
                krasig

                I can't believe.

                • 20. Re: <a4j:commandButton> and <h:messages/>

                  Something is missing to see the whole picture. Only 100% of the code can say what is missing.

                  • 21. Re: <a4j:commandButton> and <h:messages/>

                    Did you try to debug application? It may be possible to look ether you actually have a message in messages list.

                    • 22. Re: <a4j:commandButton> and <h:messages/>
                      krasig

                      This is 100% of The Code

                      PAGE:

                      <?xml version="1.0" encoding="WINDOWS-1251"?>
                      <!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:ui="http://java.sun.com/jsf/facelets"
                       xmlns:rich="http://richfaces.ajax4jsf.org/rich"
                       xmlns:h="http://java.sun.com/jsf/html"
                       xmlns:f="http://java.sun.com/jsf/core"
                       xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
                       xmlns:t="http://myfaces.apache.org/tomahawk"
                       xmlns:ft="http://sourceforge.net/projects/facestrace">
                      
                      <head>
                      <title></title>
                      
                      </head>
                      <body>
                      <ui:debug hotkey="q" />
                      <f:view>
                      
                      <a4j:outputPanel id="myMessageanel" ajaxRendered="true">
                      <h:messages />
                      </a4j:outputPanel>
                      
                      <a4j:region id="a123">
                      <h:form>
                      <h:inputText value="#{delme.id}"></h:inputText>
                      
                      <a4j:commandButton action="#{delme.searchByID}" value="221" reRender="a123"></a4j:commandButton>
                      
                      </h:form>
                      </a4j:region>
                      
                      </f:view>
                      </body>
                      
                      </html>


                      This is BEAN:
                      /**
                       *
                       */
                      package com.indexbg.dc.backing;
                      
                      import javax.faces.application.FacesMessage;
                      import javax.faces.context.FacesContext;
                      
                      import org.apache.log4j.Logger;
                      
                      import com.indexbg.dc.exceptions.ObjectNotFoundException;
                      
                      /**
                       * @author krasi
                       *
                       */
                      public class Delme extends BaseBean {
                       String id = "";
                       static final Logger LOGGER = Logger.getLogger(Delme.class);
                      
                       public Delme() {
                       }
                      
                       public String getId() {
                       FacesContext.getCurrentInstance().addMessage(
                       null,
                       new FacesMessage(FacesMessage.SEVERITY_ERROR, "??????? ? ????????? ?????????1111.",
                       ""));
                      
                       LOGGER.debug("GET 1 ------" + id);
                       if (!id.equals("")) {
                       LOGGER.debug("GET 2 ------" + id);
                       FacesContext.getCurrentInstance().addMessage(
                       null,
                       new FacesMessage(FacesMessage.SEVERITY_ERROR, "???? ??????? ????????2222.",
                       "11"));
                      
                       try {
                       LOGGER.debug("GET 3 ------" + id);
                       throw new ObjectNotFoundException();
                      
                       } catch (ObjectNotFoundException e) {
                       LOGGER.debug("GET 4 ------" + id);
                       FacesContext.getCurrentInstance().addMessage(
                       null,
                       new FacesMessage(FacesMessage.SEVERITY_ERROR, "???? ??????? ????????.",
                       "11"));
                       }
                      
                       }
                      
                       return id;
                       }
                      
                       public void setId(String id) {
                       LOGGER.debug("SET 1-" + id);
                       this.id = id;
                       }
                      
                       public String searchByID() {
                       LOGGER.debug("searchByID");
                       return null;
                      
                       }
                      
                      }



                      So. This is 1 simple page with 1 inputTex and 1 commandButon.
                      And when type some value in inputText and then press command button,
                      in the <h:message/> mus be 3 messages "RED,ORANGE and BLUE.
                      But strange is that i see only RED

                      P.S. Yes. I will post application in jira. but this not decision for me. I know that this will be corrected after 5-6-10 months when my project will be finished

                      • 23. Re: <a4j:commandButton> and <h:messages/>
                        ilya_shaikovsky

                        You wrong using such code in getter.

                        Getter called first time at the process Validations phase for taking PREVIOUS value (to generate valueChangeEvent). So id.equals("") is true and your message will NOT be added to messages list.

                        Places this code in your method and it will work as you expect I think.

                        • 24. Re: <a4j:commandButton> and <h:messages/>
                          krasig

                          Ok
                          This is debug with <a4j:commandbutton> and NO messages

                          007-8-1 0:57:18 org.exadel.jsf.PhaseTracker beforePhase
                          INFO: BEFORE RESTORE_VIEW 1
                          2007-8-1 0:57:18 org.exadel.jsf.PhaseTracker afterPhase
                          INFO: AFTER RESTORE_VIEW 1
                          2007-8-1 0:57:18 org.exadel.jsf.PhaseTracker beforePhase
                          INFO: BEFORE APPLY_REQUEST_VALUES 2
                          2007-8-1 0:57:18 org.exadel.jsf.PhaseTracker afterPhase
                          INFO: AFTER APPLY_REQUEST_VALUES 2
                          2007-8-1 0:57:18 org.exadel.jsf.PhaseTracker beforePhase
                          INFO: BEFORE PROCESS_VALIDATIONS 3
                          DEBUG - GET 1 ------ (Delme.java:getId:35)
                          2007-8-1 0:57:18 org.exadel.jsf.PhaseTracker afterPhase
                          INFO: AFTER PROCESS_VALIDATIONS 3
                          2007-8-1 0:57:18 org.exadel.jsf.PhaseTracker beforePhase
                          INFO: BEFORE UPDATE_MODEL_VALUES 4
                          DEBUG - SET 1-1 (Delme.java:setId:61)
                          2007-8-1 0:57:18 org.exadel.jsf.PhaseTracker afterPhase
                          INFO: AFTER UPDATE_MODEL_VALUES 4
                          2007-8-1 0:57:18 org.exadel.jsf.PhaseTracker beforePhase
                          INFO: BEFORE INVOKE_APPLICATION 5
                          searchByID
                          2007-8-1 0:57:18 org.exadel.jsf.PhaseTracker afterPhase
                          INFO: AFTER INVOKE_APPLICATION 5
                          2007-8-1 0:57:18 org.exadel.jsf.PhaseTracker beforePhase
                          INFO: BEFORE RENDER_RESPONSE 6
                          DEBUG - GET 1 ------1 (Delme.java:getId:35)
                          DEBUG - GET 2 ------1 (Delme.java:getId:37)
                          DEBUG - GET 3 ------1 (Delme.java:getId:44)
                          DEBUG - GET 4 ------1 (Delme.java:getId:48)
                          2007-8-1 0:57:18 org.exadel.jsf.PhaseTracker afterPhase
                          INFO: AFTER RENDER_RESPONSE 6


                          This is debug with <h:commandbutton> and messages - YES
                          2007-8-1 11:55:27 org.exadel.jsf.PhaseTracker beforePhase
                          INFO: BEFORE RESTORE_VIEW 1
                          2007-8-1 11:55:27 org.exadel.jsf.PhaseTracker afterPhase
                          INFO: AFTER RESTORE_VIEW 1
                          2007-8-1 11:55:27 org.exadel.jsf.PhaseTracker beforePhase
                          INFO: BEFORE APPLY_REQUEST_VALUES 2
                          2007-8-1 11:55:27 org.exadel.jsf.PhaseTracker afterPhase
                          INFO: AFTER APPLY_REQUEST_VALUES 2
                          2007-8-1 11:55:27 org.exadel.jsf.PhaseTracker beforePhase
                          INFO: BEFORE PROCESS_VALIDATIONS 3
                          DEBUG - GET 1 ------ (Delme.java:getId:30)
                          2007-8-1 11:55:27 org.exadel.jsf.PhaseTracker afterPhase
                          INFO: AFTER PROCESS_VALIDATIONS 3
                          2007-8-1 11:55:27 org.exadel.jsf.PhaseTracker beforePhase
                          INFO: BEFORE UPDATE_MODEL_VALUES 4
                          DEBUG - SET 1-1 (Delme.java:setId:56)
                          2007-8-1 11:55:27 org.exadel.jsf.PhaseTracker afterPhase
                          INFO: AFTER UPDATE_MODEL_VALUES 4
                          2007-8-1 11:55:27 org.exadel.jsf.PhaseTracker beforePhase
                          INFO: BEFORE INVOKE_APPLICATION 5
                          DEBUG - searchByID (Delme.java:searchByID:61)
                          2007-8-1 11:55:27 org.exadel.jsf.PhaseTracker afterPhase
                          INFO: AFTER INVOKE_APPLICATION 5
                          2007-8-1 11:55:27 org.exadel.jsf.PhaseTracker beforePhase
                          INFO: BEFORE RENDER_RESPONSE 6
                          DEBUG - GET 1 ------1 (Delme.java:getId:30)
                          DEBUG - GET 2 ------1 (Delme.java:getId:32)
                          DEBUG - GET 3 ------1 (Delme.java:getId:39)
                          DEBUG - GET 4 ------1 (Delme.java:getId:43)
                          DEBUG - GET 1 ------1 (Delme.java:getId:30)
                          DEBUG - GET 2 ------1 (Delme.java:getId:32)
                          DEBUG - GET 3 ------1 (Delme.java:getId:39)
                          DEBUG - GET 4 ------1 (Delme.java:getId:43)
                          2007-8-1 11:55:27 org.exadel.jsf.PhaseTracker afterPhase
                          INFO: AFTER RENDER_RESPONSE 6
                          


                          Will explin me that?

                          • 25. Re: <a4j:commandButton> and <h:messages/>
                            krasig
                            • 26. Re: <a4j:commandButton> and <h:messages/>

                              The h:messages is located above the input field. Try to put it somewhere below it.

                              • 27. Re: <a4j:commandButton> and <h:messages/>
                                krasig

                                No effect

                                • 28. Re: <a4j:commandButton> and <h:messages/>

                                  Ok. It will never work until you start do things in right way. Take the code out of the getter.

                                  • 29. Re: <a4j:commandButton> and <h:messages/>
                                    krasig

                                    In JIRA my last comment is:

                                    Ok. Thanks for taking the time to explain.

                                    But can you explain why when using <h:commandbutton> everything is OK???

                                    Sorry for my poor English!!