The moose likes Struts and the fly likes using logic:eual or logic present Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "using logic:eual or logic present" Watch "using logic:eual or logic present" New topic

using logic:eual or logic present

ranjan panda

Joined: Oct 03, 2005
Posts: 8
I have a form bean which contains a arraylist and two field such as; firstName and lastName. Now if the user enter anything wrong in the jsp then i am adding that fiild name in to the arraylist inside the validate method.
ArrayList list = new ArrayList();
if (FastUtil.isEmpty(firstName)) {
errors.add("firstName", new ActionMessage("30001"));
Now the requirement is inside the jsp i want to check whether that arraylist contains any specific field name or not which i am thinkig will be possible through logic:equal or logic:iterate. So that if I found any fiild name inside the arrraylist then i will change the CSS method name for highlighting the field.
Here i have to check
<input type="text" class="textfield" name="firstName" width=20
value="<bean:write property="firstName" name="dbSearchHomeForm"/>"></TD>

Please suggest how to check the arraylist and then chage the css method name accordingly.

Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
I am not very clear about the first part of the question about using ArrayList but why you do want to error messages in ArrayList and not in ActionErrors or ActionMessages? If you store your messages/errors in in the struts framework it will be lot easier as you have "messagePresent" struts logic tag which you can use to find out if the particular form element has error message or not and then change the style of the element approriately.

Search for logic: messagePresent on the web.
ranjan panda

Joined: Oct 03, 2005
Posts: 8
Hi Purushothaman ,
Thank you for your reply. I objective is get the name of those field in the jsp for which the use has sumbitted invalid data and then change the CSS class method to highlight that. And for accessing those field names I want to use ArrayList which i have defined in the form bean.I am using ActionMessage to handle errors and there is absolutely no issues with thtat.
So can you help me ahead.
I agree. Here's the link:
subject: using logic:eual or logic present
It's not a secret anymore!