JSF + Seam + a4j Triggering one component ajax from a different component event

StackOverflow https://stackoverflow.com/questions/20147727

  •  03-08-2022
  •  | 
  •  

سؤال

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!!

هل كانت مفيدة؟

المحلول 3

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

نصائح أخرى

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

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top