0

I wanted to ask just what title says: say we have a inputtext and a button. Well, I wanted to submit an ajax request in the inputtext when button is clicked.

for example, from the inputtext perspective, I want to achive something like this:

<h:inputtext>
   <a4j:support event="button.onclick"/>
<h:inputtext>
<h:button id="button">

or, from the button perspective:

<h:inputtext id="input"/> 
<h:button id="button">
   <a4j:support event="onclick" action="input.submit"/>
</h:button>

Don't know if there exist an easy way to get this done.

thanks in advance!!

McCoy
  • 780
  • 1
  • 10
  • 21

3 Answers3

0

If you just want a simple form submit, I think both approach are wrong, as long as you put your inputtext and button properly in a form, the form will automatically submit whatever you have in this form including user's input in inputtext when you click the button. There is no need to do something like input.submit yourself. (and it's not correct, either)

For the following case, you will see the setInputValue() of managed bean being invoked when you click your button.

<h:inputtext id="input" value=#{bean.inputValue}/>

public void setInputValue(String inputValue){
    this.inputValue = inputValue;
}
Paul Lo
  • 6,032
  • 6
  • 31
  • 36
  • Thanks for answering! I don't want to submit a form, I have other components I didn't specify in the sample code drafts above. I need to trigger an ajax request just for the inputtext, but, the thing is that I need to trigger it from another component, not for example from the 'onblur' in the inputtext itself, but for example from an 'onclick' action in a button – McCoy Nov 22 '13 at 19:02
0

Try using

Richfaces Region component to limit your request to diffrent regions.

http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/a4j_region.html

Trind
  • 1,583
  • 4
  • 18
  • 38
  • Thanks! I tried this too, don't know if it was in the right way but didn't work. I finally got this done using a4j:function. – McCoy Nov 26 '13 at 12:48
0

I finally get this done by means of <a4j:jsFunction> a4j:jsFunction

McCoy
  • 780
  • 1
  • 10
  • 21