Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

<s:if test="hasFieldErrors()"></s:field> Need help for this tag in struts 2  RSS feed

Jibin Najeeb
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to use the above code for two fields.
<s:form theme="simple" >
<s:if test=hasFieldErrors()">
<div class="errorMessage">Enter Bank Account</div><br>
<s:textfield name="bankaccount" cssClass="input-xlarge text-tip" id="input01" title="Bank account"/>
<s:if test="hasFieldErrors()">
<div class="errorMessage">Amount Problem</div><br>
<s:textfield name="amount" cssClass="input-xlarge text-tip" id="input01" title="Amount"/>
Note:Theme is simple

The validate function in the action class is

public void validate(){
this.addFieldError("bankaccount", "ERROR bank");
this.addFieldError("Amount", "ERROR amount");


The problem is whenever there is a field error in any one of the two field. The validation message corresponding to each is displayed for two fields.
ie ""Error bank"" above bank account field and ""ERROR amount"" above amount field.

I need to work the validation like that worked in default form theme. Any Help Appreciated..
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!