murat
murat

Reputation: 21

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;
}

Upvotes: 2

Views: 5829

Answers (1)

Ravi Kavaiya
Ravi Kavaiya

Reputation: 849

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 .

Upvotes: 2

Related Questions