Details
-
Bug
-
Status: Resolved
-
Resolution: Won't Fix
-
3.0
-
None
-
None
-
Operating System: Other
Platform: Other
-
30626
Description
I was wondering if a change I made to handle disable fields better could be an
enhancement for the future for everyone.
I found it helpful that if a field was disabled to generate the field with a
special name and also generate a hidden field with the correct name and value,
so that when the form is submitted the value for the field is not lost.
Here is the code I used in the renderComponent method:
String value;
IForm form = getForm(cycle);
// It isn't enough to know whether the cycle in general is rewinding,
need to know
// specifically if the form which contains this component is rewinding.
boolean rewinding = form.isRewinding();
// If the cycle is rewinding, but the form containing this field is not,
// then there's no point in doing more work.
if (!rewinding && cycle.isRewinding())
return;
// Used whether rewinding or not.
String name = form.getElementId(this);
if (rewinding)
{
// EG - 08/12/2004 if (!isDisabled())
// EG - 08/12/2004 {
value = cycle.getRequestContext().getParameter(name);
// EG - 08/12/2004 Start Add
if (value != null)
return;
}
writer.beginEmpty("input");
writer.attribute("type", isHidden() ? "password" : "text");
if (isDisabled())
// EG - 08/12/2004 Start Add
else
{ // EG - 08/12/2004 End Add writer.attribute("name", name); // EG - 08/12/2004 Start Add }// EG - 08/12/2004 End Add
value = readValue();
if (value != null)
writer.attribute("value", value);
renderInformalParameters(writer, cycle);
beforeCloseTag(writer, cycle);
writer.closeTag();
// EG - 08/12/2004 Start Add
if (isDisabled())
{
if (value != null)
else
{ form.addHiddenValue(name, ""); } }
// EG - 08/12/2004 End Add