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

怎甘沉沦 提交于 2019-12-11 23:23:26

问题


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


回答1:


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



回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/20147727/jsf-seam-a4j-triggering-one-component-ajax-from-a-different-component-event

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!