5 Replies Latest reply on Apr 20, 2015 3:44 AM by michpetrov

    Incorrect data update of rich:panelMenu

    shmu80

      Hi,

      I found the current item update in rich:panelMenu is late and incorrect. Below is my code.

       

      sideNavi.xhtml

      <rich:panelMenu itemMode="ajax" groupMode="ajax" groupExpandedLeftIcon="triangleUp"

                      groupCollapsedLeftIcon="triangleDown" topGroupExpandedRightIcon="chevronUp"

                      topGroupCollapsedRightIcon="chevronDown" itemLeftIcon="disc" itemChangeListener="#{navBean.updateCurrent}"

                      activeItem="#{navBean.current}">               

              <rich:panelMenuGroup id="accessRight" label="Access Right">

                  <rich:panelMenuItem id="roleMain" label="Role" action="#{roleBean.init}"/>

              </rich:panelMenuGroup>

              <rich:panelMenuGroup id="information" label="Information">

                  <rich:panelMenuItem id="categoryMain" label="Category" action="#{categoryBean.init}"/>

              </rich:panelMenuGroup>

          </rich:panelMenu>

       

      NavBean.java

      public class NavigatorBean implements Serializable {

         

          private static final Logger logger = Logger.getLogger(NavigatorBean.class

                  .getName());

                 

          private static final long serialVersionUID = -3570134693650857646L;

          private String current;

          private boolean singleMode;

       

          public boolean isSingleMode() {

              return singleMode;

          }

       

          public void setSingleMode(boolean singleMode) {

              this.singleMode = singleMode;

          }

       

          public String getCurrent() {

              return this.current;

          }

       

          public void setCurrent(String current) {

              this.current = current;

          }

       

          public void updateCurrent(ItemChangeEvent event) {

              if (logger.isLoggable(Level.INFO)) {

                  logger.info("Current event item name: " + event.getNewItemName());

              }

              setCurrent(event.getNewItemName());

          }

      }

       

      The situation:

      1. I have 2 rich:panelMenuItem, category and role.
      2. When I click on category, no data log.
      3. After that when I click on Role, the log wil display "Current event item name: roleMain" and then follow by "Current event item name: categoryMain", so the activeItem will jump to categoryMain even I just click on Role.

       

      Please advise.

        • 1. Re: Incorrect data update of rich:panelMenu
          michpetrov

          Works for me. What does your web.xml look like? Also what version of RichFaces and JSF are you using?

          • 2. Re: Incorrect data update of rich:panelMenu
            shmu80

            Hi,

            Thanks for the reply. Below is my project information.

             

            Richfaces version is 4.5.2

            JSF version is 2.2 (where by I am using jsf-api 2.2.9 library)

             

            This is my web.xml

             

            <?xml version="1.0" encoding="UTF-8"?>

            <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

               

                <display-name>Testing</display-name>

                <context-param>

                    <param-name>javax.faces.FACELETS_LIBRARIES</param-name>

                    <param-value>/WEB-INF/app-tags.taglib.xml</param-value>

                </context-param>

                <context-param>

                    <param-name>javax.faces.PROJECT_STAGE</param-name>

                    <param-value>Development</param-value>

                </context-param>

                <context-param>

                    <param-name>org.richfaces.fileUpload.maxRequestSize</param-name>

                    <param-value>100000</param-value>

                </context-param>

                <context-param>

                    <param-name>org.richfaces.fileUpload.createTempFiles</param-name>

                    <param-value>false</param-value>

                </context-param>

                <context-param>

                    <param-name>org.richfaces.resourceOptimization.enabled</param-name>

                    <param-value>true</param-value>

                </context-param>

                <context-param>

                    <param-name>javax.faces.SKIP_COMMENTS</param-name>

                    <param-value>true</param-value>

                </context-param>

               

                <!-- Plugging the "Blue Sky" skin into the project -->

                <context-param>

                    <param-name>org.richfaces.SKIN</param-name>

                    <param-value>blueSky</param-value>

                </context-param>

             

                <!-- Making the RichFaces skin spread to standard HTML controls -->

                <context-param>

                    <param-name>org.richfaces.CONTROL_SKINNING</param-name>

                    <param-value>enable</param-value>

                </context-param>

               

                <servlet>

                    <servlet-name>Faces Servlet</servlet-name>

                    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

                    <load-on-startup>1</load-on-startup>

                </servlet>

                <servlet-mapping>

                    <servlet-name>Faces Servlet</servlet-name>

                    <url-pattern>*.jsf</url-pattern>

                </servlet-mapping>

                <servlet-mapping>

                    <servlet-name>Faces Servlet</servlet-name>

                    <url-pattern>/faces/*</url-pattern>

                </servlet-mapping>

               

                <!-- Resource Servlet - serves static resources and resources for specific components -->

                <servlet>

                    <servlet-name>Resource Servlet</servlet-name>

                    <servlet-class>org.richfaces.webapp.ResourceServlet</servlet-class>

                    <load-on-startup>1</load-on-startup>

                </servlet>

                <servlet-mapping>

                    <servlet-name>Resource Servlet</servlet-name>

                    <url-pattern>/org.richfaces.resources/*</url-pattern>

                </servlet-mapping>

               

                <!-- Resource Mapping - resources will be served compressed and packed in production -->

                <context-param>

                    <param-name>org.richfaces.resourceMapping.enabled</param-name>

                    <param-value>true</param-value>

                </context-param>

               

                <listener>

                    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>

                </listener>

             

                <session-config>

                    <session-timeout>30</session-timeout>

                </session-config>

             

                <welcome-file-list>

                    <welcome-file>faces/index.xhtml</welcome-file>

                </welcome-file-list>

                <mime-mapping>

                    <extension>xcss</extension>

                    <mime-type>text/css</mime-type>

                </mime-mapping>

                <login-config>

                    <auth-method>BASIC</auth-method>

                </login-config>

             

            </web-app>

            • 3. Re: Incorrect data update of rich:panelMenu
              michpetrov

              That looks ok, can you try putting <a4j:log> on your page and see what's happening?

              • 4. Re: Incorrect data update of rich:panelMenu
                shmu80

                I can't found the issue after verify the a4j:log, but I notice some behavior is weird. The validation method will been trigger 3 times in a single action. I am wondering how this will happen.

                 

                Code

                ---------------------

                @AssertTrue(message = "Login Failed")

                    public boolean isLoginUserValid() {

                        boolean result = false;

                        User entity = null;

                        try {

                            entity = new User();

                            entity.setLoginId(this.loginId);

                            this.user = this.checkMethod.verifyUser(entity);

                            if (logger.isLoggable(Level.INFO)) {

                                logger.info("Login test: " + entity.toString() + "\n Value: "

                                        + this.user);

                            }

                            if (this.user != null) {

                                if (logger.isLoggable(Level.INFO)) {

                                    logger.info("Same password");

                                }

                                return true;

                            }

                        } catch (Exception e) {

                            return false;

                        }

                        return result;

                    }

                -------------------------------

                 

                Log message

                --------------------------------

                Capture.JPG

                Please advise.

                • 5. Re: Incorrect data update of rich:panelMenu
                  michpetrov

                  I don't see where the method is called from, is it a problem that it's called multiple times?