Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Not A Problem
-
2.0.11.2
-
None
-
None
-
Windows XP, Websphere, JSP
Description
Apache documentation show simple s:if test usage. e.g. s:if test="%
{mode=='AddEdit'}"I try to use a little more complex test s:if test="%{mode=='AddEdit'}
&& %
{id==null}" and it fail to evaluate properly.EmployeeUsername is assigned when created. Once created it should not be changed while other field like first name may be changed. There are 3 modes (Add/Edit/ViewOnly)
Here is the sample code that somehow works. It allow data entry in employeeUsername in Add/Edit mode. The problem is it allow data entry after username is assigned.
<s:if test="%{mode=='AddEdit'}">
<td><s:textfield name="employeeUsername"/></td>
</s:if>
<s:else>
<td><s:textfield name="employeeUsername" readonly="true"/></td>
</s:else>
Here is code that try to fix the above problem but do not work (The textfield is always readonly even when mode is 'AddEdit' and id is really null).
<s:if test="%{mode=='AddEdit'} && %{id==null}
">
<td><s:textfield name="employeeUsername"/></td>
</s:if>
<s:else>
<td><s:textfield name="employeeUsername" readonly="true"/></td>
</s:else>
I got around the problem with 2 individual s:if test but that is a ugly solution.
Is this a OGNL problem (OGNL document say and/or is allowed)?
Is this a struts s:if tag problem or simply s:if limitation? There is simply no documentation that said s:if support this behavior or not.