How can I pass value from jQuery to jsf h:inputText and Backing Bean

I try to pass value from jquery to jsf and Backing Bean. And in the process, I do not want to use f:ajax from jsf-Tag.

javaScript or jQuery

<script>
   var myvalue = null;
   $('.classname').live('click',function(){
      myvalue = "thisvalue"+xyz;  
      // update myvalue in jsf inputtext and in bean
   });
</script>

JSF - Content

<h:form id="myid" prependId="false">

  <h:inputText id="fragment" value="#{myBean.changevalue}">
  <!-- please do not use here f:ajax or p:ajax so on. -->

</h:form>

Bean Content

private String changevalue;

public String getChangevalue() {
  return changevalue;
}

public void setChangevalue(String changevalue) {
  this.changevalue = changevalue;
}

Answers:

Answer

just you have to set val to browser textbox id in jquery

for example

 <script>
   var myvalue = null;
   $('.classname').live('click',function(){
      myvalue = "thisvalue"+xyz;  

     $("#myid\\:fragment").val(myvalue);

   });
</script>

it will automatically bind value to your bean

hope it's help for you .

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.