retrieve value from Parameters Map sent by Javascript Function generated by p:remoteCommand does not work

323 views Asked by At

Many tickets had been raised related to this issue :

  1. How do you pass parameters(from javascript) into remoteCommand(& then send it to backing beans)?
  2. Pass parameter to p:remoteCommand from JavaScript

  3. Supplying parameters through p:remoteCommand to a Spring bean

The nearest Issue to this ticket is the last one ( Supplying parameters through p:remoteCommand to a Spring bean )

Indeed , i have as:

JSF view:

<h:form>
   <p:remoteCommand name="myFn" actionListner="#{personBean.updateProfile}" />
</h:form>

Spring managed bean:

@Controller
@Scope("request")
@Qualifier("personBean")
    public class PersonBean{

         //.............
    @Value("#{request.getParameter('idSelected')}")
     private Long idSelected;
         //.................

        public void  updateProfile(){
                 // print parameters' map [key1=value1,key2=value2,....]
                System.out.println(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap());


         }
    }

Calling the Javascript Function myFn({idSelected:670}) triggers the Backing Bean method updateProfile, since , the console prints :

 {execution=e6s2,idSelected=670, javax.faces.partial.ajax=true,javax.faces.source=j_idt105:j_idt106,....} 

As you note idSelected has been passed successfully as parameter . However :

FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get('idSelected') return null .

FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get('idSelected'); 
// return NULL !!!

If the Type of Paramters Map is Map<String,String> , why there is no value even the printing of the whole map displays idSelected=670 ?

if .get('idSelected') [ in general .get(<KEY>)] does not work , there is another way to retrieve the param-value given the param-name(key)?

0

There are 0 answers