Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use RichFaces a4j:commandButton not using submit

I have an a4j:commandButton which looks like this

    <a4j:commandButton id="stopBtn" type="button" reRender="lastOp"
  action="#{MyBacking.stop}" value="Stop" />
 </a4j:commandButton>

When the app is deployed, and the button clicked, the stop() method is not being called. All the a4j:commandButton examples refer to forms, but this button is not in a form - it's a button the user is going to use to cause the server to run some back-end logic. At the moment, the method is

    public void stopNode() {
 logger.info("STOPPING");
 setLastOp("Stopped.");
}

Other methods which don't use this type of button are updating the lastOp field, but I'm not seeing anything on the console with this one. Am I right to cast this as a button? Should I put this in a h:form tag?

The firebug console says:

this._form is null

which I don't understand.

Any help well appreciated.

like image 368
volvox Avatar asked Aug 17 '26 07:08

volvox


1 Answers

UICommand components ought to be placed inside an UIForm component. So, your guess

Should I put this in a h:form tag?

is entirely correct :) This because they fire a POST request and the only (normal) way for that is using a HTML <form> element whose method attribute is set to "post". Firebug also says that a parent form element is been expected, but it resolved to null and thus no actions can be taken place.

Only "plain vanilla" links like h:outputLink and consorts doesn't need a form, because they just fires a GET request.

like image 69
BalusC Avatar answered Aug 18 '26 20:08

BalusC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!