aspose file tools*
The moose likes Struts and the fly likes <s:if test= Need help for this tag in struts 2" title="" /> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "<s:if test="hasFieldErrors()"></s:field> Need help for this tag in struts 2" Watch "<s:if test="hasFieldErrors()"></s:field> Need help for this tag in struts 2" New topic
Author

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

Jibin Najeeb
Greenhorn

Joined: Nov 27, 2012
Posts: 6
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:if>
<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:if>
<s:textfield name="amount" cssClass="input-xlarge text-tip" id="input01" title="Amount"/>
</s:form>
Note:Theme is simple

The validate function in the action class is

public void validate(){
if((bankaccount==null)||bankaccount.length()==0){
this.addFieldError("bankaccount", "ERROR bank");
}
if((amount==0.0)){
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..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: <s:if test="hasFieldErrors()"></s:field> Need help for this tag in struts 2
 
Similar Threads
appfuse validation problem
Struts2 & validation [SOLVED]
How to retain automatically generated fields on pageload in struts2
RadioButton with List Struts 2
Struts2 - textfield - required attribute doesn't work