Reputation: 103
I am trying to set the text in a button to either 'Enable' or 'Submit' depending on the value of a action class member(mode). But it is reporting an error which is saying 'equal symbol expected' on the first line. I searched and found that there are questions regarding 'equal symbol expected' error but nothing specific to Struts 2 tags. Neither I could spot any obvious error as missing closing quotes.
It would be nice if anyone can help.
<s:set name="submitButtonLabel" value="<s:if test="mode.equals('enable')">Enable</s:if> <s:else>Submit</s:else>" />
<s:submit value = "%{#submitButtonLabel}" cssClass="btn btn-gray" />
Upvotes: 0
Views: 1657
Reputation: 10017
Try this:
<s:submit value="%{mode.equals('enable') ? 'Enable' : 'Submit'}" />
Upvotes: 3
Reputation: 24396
You cannot nest tags like that. Write your <s:if>
inside <s:set>
tag instead.
<s:set name="submitButtonLabel">
<s:if test="mode.equals('enable')">Enable</s:if>
<s:else>Submit</s:else>
</s:set>
Upvotes: 2