aroy
aroy

Reputation: 103

struts 2: equal symbol expected error

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

Answers (2)

Jaiwo99
Jaiwo99

Reputation: 10017

Try this:

<s:submit value="%{mode.equals('enable') ? 'Enable' : 'Submit'}" />

Upvotes: 3

Aleksandr M
Aleksandr M

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

Related Questions