Note that there are some explanatory texts on larger screens.

plurals
  1. POStruts2 form with two buttons -- action not being processed correctly
    primarykey
    data
    text
    <p>I've tried searching the forums for the answer to this, and I've been unsuccessful. I have a Struts2 form with two buttons, and I want the action class to perform a different action depending on which button was pressed. That's not happening. Can anyone help me with this? Here is my form, followed by the action class.</p> <pre><code> &lt;s:form action="ApproveBulletin" method="post"&gt; &lt;table&gt; &lt;tr&gt; &lt;td colspan="2"&gt;&lt;b&gt;From:&lt;/b&gt; &lt;s:property value="name" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt;&lt;b&gt;Subject:&lt;/b&gt; &lt;s:property value="subject" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt;&lt;b&gt;Date:&lt;/b&gt; &lt;s:property value="date" /&gt; &lt;br&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt;&lt;s:property value="note" /&gt; &lt;s:hidden name="id" value="%{id}" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;s:submit type="button" name="approve" value="approve" label="Approve" /&gt;&lt;/td&gt; &lt;td&gt;&lt;s:submit type="button" name="deny" value="deny" label="Deny" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;br /&gt; &lt;/s:form&gt; public String execute() { BulletinDAO bulletinDAOInstance = new BulletinDAO(); if ("Approve".equals(buttonName)) { if (bulletinDAOInstance.approveBulletin(id) == true) { return "redirect"; } } if ("Deny".equals(buttonName)) { if (bulletinDAOInstance.denyBulletin(id) == true) { return "redirect"; } } return "failure"; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload