1

myBean is in request scope.

<h:form id="indexFormID">
<a4j:outputPanel ajaxRendered="true" layout="block">
    <h:inputText id="inputForHD" value="#{myBean.inputParam}"></h:inputText>
    <a4j:commandLink value="Submit" action="#{myBean.myMethod}" reRender="renderSuccess" process="indexFormID:inputForHD"></a4j:commandLink>
</a4j:outputPanel>


 <h:panelGroup id="renderSuccess">
    <h:panelGroup rendered="#{myBean.someBoolean}">
       //Some other JSF components go here          
    </h:panelGroup>
 </h:panelGroup>
</h:form>

MyBean class definition:

private String inputParam;
//Getters and setters are there

public String myMethod()
{
    log.debug("~ Value of inputParam" +this.getInputParam()); //This is printing null value for inputParam 
    //when commandLink is clicked
    return null;
}

Why my inputParam is not getting set with the input parameters?

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
Vikas V
  • 3,176
  • 2
  • 37
  • 60

1 Answers1

0

Ok I found few issues with your approach:

<h:inputText id="inputForHD" value="#{myBean.inputParam}"></h:inputText>

You are already mapping the inputParam attribute with this bean, why have a new Id "inputForHD"

Use the inputParam itself, if you want to use inputForHD, you can pick the same from request Parameter map like.

String inputForHD = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("indexFormID:inputForHD");

Also as I mentioned previously wrap the output panel inside the and a4j panel e.g.

     <h:panelGroup id="renderSuccess">
        <h:panelGroup rendered="#{helloWorld.someBoolean}">
           //Some other JSF components go here
           <h:inputText id="inputForHDasdasd" value="#{helloWorld.inputParam}"></h:inputText>
        </h:panelGroup>
     </h:panelGroup>

This is working fine, let know if any issues.

Himanshu Bhardwaj
  • 4,038
  • 3
  • 17
  • 36
  • Looks like `myBean.myMethod` is managing the value for `myBean.someBoolean` based on the value of `myBean.inputParam`, so is ok if `myBean.someBoolean` is `false` and then it becomes `true` (note that OP doesn't rerender the `h:panelGroup` instead the wrapper `UIContainer` ``). – Luiggi Mendoza Apr 16 '13 at 04:36
  • Yes that's what I think too, that's why I asked that it doesn't resolve to "false" after method, else it will not be rendered. I believe if the outer container is rerendered the inner components rerender by self. That's supposed to be the way. – Himanshu Bhardwaj Apr 16 '13 at 04:40
  • The problem is that OP isn't sending the right ID for the `` in the `process` attribute of ``. See my answer for a solution. – Luiggi Mendoza Apr 16 '13 at 04:42
  • That I have already seen nor am I contradicting that. I was replying to your comment. – Himanshu Bhardwaj Apr 16 '13 at 04:45
  • @HimanshuBhardwaj Tried with your updated answer. But, still am not getting the actual value entered. I am still getting `null` value. I even changed scope of myBean to `session` and changed `getRequestParameterMap` to `getSessionMap`. Even then it didn't work! – Vikas V Apr 16 '13 at 06:07
  • No need to convert to session scope, move back to request. 1. Remove the process tag attribute for now. 2. Put a debug pointer on myMethod, and paste the values for getRequestParameterMap 3. Share you updated JSF and Bean. – Himanshu Bhardwaj Apr 16 '13 at 06:12