0

actually i have a inputTextarea , and i want to get the value from it and append some values, before action takes place in BackingBean. how to achieve this! I tried but the a4j:commandLink does not invoke action after calling javascript on onClick event.

i refers this reference action method is not called in <a4j:commandLink> tag

How can I execute Javascript before a JSF <h:commandLink> action is performed?

http://balusc.blogspot.in/2009/05/javajspjsf-and-javascript.html Actually My code:

JavaScript in common file

 function call()
    {
        var test= document.getElementById('inputId').value;
      test="hai"; //some code

     document.getElementById('inputId').value=test;
return true;
    }

in jsf
<a4j:commandLink onclick="if (!call()) return false;"
    action="#{bean.createUser()}"
    execute="@form">
    <h:graphicImage style="border-style:none;" url="/images/create.jpg"
        height="10px" />
</a4j:commandLink>
Community
  • 1
  • 1
user_vs
  • 1,021
  • 3
  • 16
  • 29

1 Answers1

0

you can use a native html link and an a4j:jsFunction to achieve that.

<a href="#" onclick="appendFunctionHere(); jsFunctionToCallAction(); return false;">Click</a>

<a4j:jsFunction name="jsFunctionToCallAction" action="#{myManagedBean.myActionMethod}" ... />
tt_emrah
  • 1,043
  • 1
  • 8
  • 19
  • i have tried this... but the action bean is not invoking – user_vs Oct 24 '14 at 10:27
  • well, it doesn't seem to be related to my solution, right? :) – tt_emrah Oct 24 '14 at 10:42
  • i am very thankful to you ...for your response..but...i need in this way.because i cant change the jsf tag. what shall i do..??? – user_vs Oct 24 '14 at 10:48
  • sure, no problem. but can i ask why you cannot change the jsf tag? maybe we can find a simple answer for that, too. – tt_emrah Oct 24 '14 at 10:51
  • Due to the requirement by Software Architects..if i get simple solution without changing and affecting the design and tag... and i am new in it...and just getting into it..if i could get simple solution within time limited time period..it would be a..help – user_vs Oct 24 '14 at 10:54