• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts 2 - How do I remove validation messages from fields?

 
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm using struts 2 in my project and I don't want to display error messages on top of fields. What I need to know is, how do I customize validation framework so it will not show messages on top of each field which validation has failed??? This causes a mess up with my css design!!!

I have already configured the error messages to appear on top of pages when some validation error occurs but I was not able to disable the field messages to appear. I'm sure there's some way to accomplish that.

[]s
Marcos Maia.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use the "simple" theme: Struts 2 FAQ: Who do the form tags put table tags around controls
 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Ess wrote:Use the "simple" theme: Struts 2 FAQ: Who do the form tags put table tags around controls



Tx for this tip.That's what i need. The simple theme is not an option for me as I'll loose tooltips and will have to manually add label to fields. But following your suggestion I found out how to customize a template for my needs.

http://struts.apache.org/2.1.6/docs/template-loading.html
http://struts.apache.org/2.1.6/docs/extending-themes.html

Struts 2 rocks!



[]s
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let us know how it works out. There's been a lot of discussion about templates being painful to work with (I've never tried). We can always use another point of view.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They're not difficult if you're comfortable with templating languages. There are several includes for most tags, but the contents of each are (usually) self-explanatory.
 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I took a quick look yesterday(1 hour) and as I'm not confortable with template languages it does not seemed too trivial. I have tryied some modification on template files but with no success. I'm using Appfuse and I already have found 3 templates under /template/xhtml and nothing seems to change when I change this templates. I think I'm still doing something wrong. I'll post my progress here.
Follows the template I believe I should customize to meet my requirements (controlheader-core.ftl):


[]s


 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have foun some more good information on xhtml theme on struts site: http://struts.apache.org/2.1.6/docs/xhtml-theme.html . Including a note on changing error message.

[]s
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't really read that.

Did you extract them to your classpath or webapp?
 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hum... I'll try posting it again!


 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See,

what I'm trying to acoplish is removing the message from the field but leaving the icon(warning) on label side to show which fields have failed validation. The messages I'll leave on top only, wich is default using struts Appfuse templates.

[]s
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I wrote: Did you extract them to your classpath or webapp?


The code that displays field messages is still there:
 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

after a bit of modification I'm almost where I wanna to be. I have changed label entry to not became red anymore when error occurs so it's now like:


Also I have removed error message and left warnin icon:

The only thing I'm not able to do yet is to post the warnin icon on top(on label side) .
The icon is actually pushing the textfield and being placed on it's left side. I'd like it to be after the label text for the field, same line.

What I have is like:

label for field
icon - textfield

I want it to be like:

label for field - warning icon
textfield

I still didn't get which code fragment places a line between label and icon.



 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's done.

It took me 3.5 hours to acomplish this task. This time I have used to post here, some reading and research on web and trying with code changes in templates. For someone who never had work with template languages before I believe its a fair time. My final word on this is that doesn't look that hard to learn Freemarker templates and customizing the ones already there is not such a big deal.

In my final template i moved the place where warning icon was placed on template and it's working as expected now.


[]s

 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm posting images from what I get here.....

well...

I was not able to post images from blogspot so I'm posting a link to a post where you can see the images:

http://mmaiacupoffcoffe.blogspot.com/2009/03/struts-2-customizando-elementos-de-form.html

The post is in portuguese(I'm from Brazil) but you'll easily find the images(the only ones on this link).

Tx for tips and help provided.
regards,
[]s
Marcos Maia


 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The correct link to my blog post on this: http://mmaiacupofcoffee.blogspot.com/2009/03/struts-2-customizando-elementos-de-form.html

[]s
Marcos Maia
 
Won't you be my neighbor? - Fred Rogers. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic