JSF + Seam + a4j Triggering one component ajax fro

2019-09-02 12:34发布

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

标签: ajax jsf seam
3条回答
叛逆
2楼-- · 2019-09-02 13:19

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

查看更多
狗以群分
3楼-- · 2019-09-02 13:30

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

查看更多
该账号已被封号
4楼-- · 2019-09-02 13:36

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;
}
查看更多
登录 后发表回答