Note that there are some explanatory texts on larger screens.

plurals
  1. POSubmitting form with select and textfield as disabled and hidden fields. Values not stored properly
    primarykey
    data
    text
    <p>I have a screen where i want the components disabled when i first traverse to the screen(view mode). When i click on Edit button an action is fired and i reload the same screen with the components (cName and cStatus) as editable. Previously, i couldn't retain the values of cID, cName and cStatus when the screen was reloaded so i made 3 hidden fields with the same names. Now i am able to retain the values of all the 3 pages in editable mode(modify mode). </p> <pre><code> &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt; &lt;%@ taglib prefix="s" uri="/struts-tags"%&gt; &lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;s:form name="c" validate="true"&gt; &lt;s:hidden name="cID" /&gt; &lt;s:hidden name="cName" /&gt; &lt;s:hidden name="cStatus" /&gt; &lt;table cellspacing="0" cellpadding="3"&gt; &lt;tr&gt; &lt;s:if test="%{mode=='view'}"&gt; &lt;td&gt;&lt;s:submit name="btnEdit" value="Edit" onclick="onEdit()" /&gt;&lt;/td&gt; &lt;/s:if&gt; &lt;s:elseif test="%{mode=='modify'}"&gt; &lt;td&gt;&lt;s:submit name="btnSave" value="Save" onclick="onSave()" /&gt;&lt;/td&gt; &lt;/s:elseif&gt; &lt;td&gt;&lt;s:submit name="btnBack" value="Back" onclick="onBack()" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;fieldset style="width: 60%"&gt;&lt;legend&gt;Details&lt;/legend&gt; &lt;table cellspacing="0" cellpadding="5" width="100%"&gt; &lt;tr&gt; &lt;td&gt;&lt;s:label name="ID" value="ID" /&gt;&lt;/td&gt; &lt;td&gt;&lt;s:label name="cID" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;s:label name="Name" value=" Name" /&gt;&lt;/td&gt; &lt;s:if test="%{mode=='view'}"&gt; &lt;td&gt;&lt;s:textfield name="cName" disabled="true" /&gt;&lt;/td&gt; &lt;/s:if&gt; &lt;s:elseif test="%{mode=='modify'}"&gt; &lt;td&gt;&lt;s:textfield name="cName" id="id2" /&gt;&lt;/td&gt; &lt;/s:elseif&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;s:label name="CStatus" value="Status" /&gt;&lt;/td&gt; &lt;s:if test="%{mode=='view'}"&gt; &lt;td&gt;&lt;s:select name="cStatus" list="#{'Y':'Active', 'N':'Inactive'}" disabled="true" /&gt;&lt;/td&gt; &lt;/s:if&gt; &lt;s:elseif test="%{mode=='modify'}"&gt; &lt;td&gt;&lt;s:select name="cStatus" list="#{'Y':'Active','N':'Inactive'}" /&gt;&lt;/td&gt; &lt;/s:elseif&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/fieldset&gt; &lt;/s:form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Now my problem is that, suppose if i have value "xyz" in cName and "Single" in cStatus. In modify mode i change the values to "xyza" in cName and "Married" in cStatus and submit the form. In action class i receive the Value Object set as cName="xyz, xyza" cStatus="Single, Married" instead of cName="xyza" cStatus="Married" </p>
    singulars
    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.
 

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