javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-2617

f:viewParam is lost after an f:ajax listener is run

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Incomplete
    • Affects Version/s: 2.1.7, 2.1.14
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      GlassFish 3.1.2.2, JBoss AS 7.1.1

      Description

      The values of f:viewParam components are lost after the processing of an f:ajax listener. For example, if there is an f:ajax listener to an input component for a valueChange event and that event is fired, when a postback is invoked using a commandButton, the view parameter's value is null. If the valueChange event does not fire, the view parameter is retained.

      I've included a simple example WAR that demonstrates this. Deploy and visit /example/example.jsf?param=test. Click submit button and the view parameter stays. Click the checkbox (which has an AJAX valueChange listener) then submit and the view parameter is cleared.

        Issue Links

          Activity

          Hide
          Ed Burns added a comment -

          Can you please paste the source for Example.java here?

          Show
          Ed Burns added a comment - Can you please paste the source for Example.java here?
          Hide
          breilly added a comment -

          Including both Example.java and example.xhtml, since those are the only 2 source files.

          Example.java
          package example;
          
          import javax.faces.bean.ManagedBean;
          import javax.faces.bean.RequestScoped;
          
          @ManagedBean
          @RequestScoped
          public class Example {
          
              private String param;
          
              public void noOp() {
                  System.out.println("noOp");
              }
          
              public String getParam() {
                  return param;
              }
          
              public void setParam(String param) {
                  this.param = param;
              }
          }
          
          example.xhtml
          <?xml version="1.0" encoding="UTF-8"?>
          <!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:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">
          <h:head>
              <f:metadata>
                  <f:viewParam name="param" value="#{example.param}"/>
              </f:metadata>
          </h:head>
          <h:body>
              <p>Param: #{example.param}</p>
              <h:form>
                  <p>
                      Clear viewParam
                      <h:selectBooleanCheckbox>
                          <f:ajax event="valueChange" listener="#{example.noOp}"/>
                      </h:selectBooleanCheckbox>
                  </p>
                  <h:commandButton value="Submit" action="#{example.noOp}"/>
              </h:form>
          </h:body>
          </html>
          
          Show
          breilly added a comment - Including both Example.java and example.xhtml, since those are the only 2 source files. Example.java package example; import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; @ManagedBean @RequestScoped public class Example { private String param; public void noOp() { System .out.println( "noOp" ); } public String getParam() { return param; } public void setParam( String param) { this .param = param; } } example.xhtml <?xml version= "1.0" encoding= "UTF-8" ?> <!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:h = "http://java.sun.com/jsf/html" xmlns:f = "http://java.sun.com/jsf/core" > <h:head> <f:metadata> <f:viewParam name= "param" value= "#{example.param}" /> </f:metadata> </h:head> <h:body> <p> Param: #{example.param} </p> <h:form> <p> Clear viewParam <h:selectBooleanCheckbox> <f:ajax event= "valueChange" listener= "#{example.noOp}" /> </h:selectBooleanCheckbox> </p> <h:commandButton value= "Submit" action= "#{example.noOp}" /> </h:form> </h:body> </html>
          Hide
          Manfred Riem added a comment -

          Can you reproduce the problem with latest 2.1 release?

          Show
          Manfred Riem added a comment - Can you reproduce the problem with latest 2.1 release?
          Hide
          Manfred Riem added a comment -

          Lowering priority because of no response

          Show
          Manfred Riem added a comment - Lowering priority because of no response
          Hide
          Manfred Riem added a comment -

          Lowering priority because of no response

          Show
          Manfred Riem added a comment - Lowering priority because of no response
          Hide
          Manfred Riem added a comment -

          Closing because of inactivity

          Show
          Manfred Riem added a comment - Closing because of inactivity

            People

            • Assignee:
              Unassigned
              Reporter:
              breilly
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: