I'm using a RichFaces commandbutton and I need it to execute two functions on click, one after the other. Right now, I have the code like so:
<a4j:commandButton styleClass="btn-hide"
onl
开发者_高级运维 id="btnId"
type="submit"
value="addNew"
rendered="true"
reRender="panel"
eventsQueue="eventQueue"
status="eventQueue"
actionListener="#{(someMethod.something)}"
oncomplete="javascript:something;this.disabled=false"
onclick="Bean.setDesc(document.getElementById('inputArea').value);this.disable=false"
ignoreDupResponses="true"
immediate= "true">
<s:conversationId></s:conversationId>
</a4j:commandButton>
If you look at the onclick portion, I need the Bean.setDesc to run first and then this.disabled=false. How would I go about doing this chronologically?
Thanks
Here's a code stub to get you started. You'll want to use a4j:jsFunction if you are looking to grab values directly from the client and pass them to a server method with javascript.
<h:form id="form1" prependId="false">
<a4j:jsFunction
name="setDesc"
action="#{exampleBean.actionMethod()}"
immediate="true">
<a4j:param name="inputAreaValue" assignTo="#{exampleBean.desc}"/>
</a4j:jsFunction>
<h:commandButton id="button" onclick="setDesc(document.getElementById('inputArea').value); this.disabled = true;" />
</h:form>
and the managed bean:
@ManagedBean(name = "exampleBean")
@SessionScoped
public class ExampleBean implements Serializable {
private static final long serialVersionUID = 6823632613070575039L;
private String desc;
public String getDesc() { return desc; }
public void setDesc(String desc) { this.desc = desc; }
/**
* Action Method
*/
public void actionMethod() {
// do something here
}
}
精彩评论