aspose file tools*
The moose likes Struts and the fly likes Struts 2.1 error message breaks page html formatting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2.1 error message breaks page html formatting" Watch "Struts 2.1 error message breaks page html formatting" New topic
Author

Struts 2.1 error message breaks page html formatting

E Robb
Ranch Hand

Joined: Aug 27, 2010
Posts: 111
Im having some issues where error messages are making the page formatting of forms look odd. It essentially offsets the label from the text field so the two do not line up together.

I've tried overriding the css and it does seem to resolve the issue. Is this something I need to make custom freemarker templates for or am I missing something really simple?

I know this is not the way I should confirm / change a password for now I am just trying to get the look and feel of the error pages correct.

The first screen shot shows how the page loads the second screen shot shows how the errors throw the label and field out of alignment. Ideally I would like the error message to start over the label table cell and go to the right instead of starting over the field cell of the html and going to the right.

Here is the CSS I have tried:



Here is the actual form using theme="css_xhtml".


validation.xml:



[Thumbnail for Labels_Outof_Alignment.jpg]


[Thumbnail for pageLoad.jpg]

vanlalhmangaiha khiangte
Ranch Hand

Joined: Sep 11, 2006
Posts: 170
Hi ,

I also got the same problem and had fixed it by following this tutorial http://www.mkyong.com/struts2/working-with-struts-2-theme-template/


Regards,
Vanlal
E Robb
Ranch Hand

Joined: Aug 27, 2010
Posts: 111
It looks like my html usage of css_xhtml theme was not proper which was causing the issue where the error messages were causing the labels to misalign with the text fields. I have changed my html form to the following:



Now my error messages are spanning the div correctly & the field labels are not misaligning vertically but it is changing the layout of the form. is some label I am missing to keep the elements from jumping from aligning center to aligning left?



[Thumbnail for incorrectRendering.png]

[Thumbnail for correctRendering.png]

E Robb
Ranch Hand

Joined: Aug 27, 2010
Posts: 111
Was able to resolve the issue by over riding the css with the following. Now creates errors that produce a layout that is the same as the original display




[Thumbnail for security_fixed.jpg]

ss bb
Greenhorn

Joined: Mar 28, 2011
Posts: 2
Hi I am new to code ranch

I have problem with alignment using <s:form theme="css_xhtml">

Here is my code in jsp


Here are images to describe my problem

1) I have a form here.


2) When I submit, the <s:textfield> move to the right


3) This is what I want instead


ss bb
Greenhorn

Joined: Mar 28, 2011
Posts: 2
Problem solved. But in the first place there isn't any problem >.<

The reason why the alignment is weird is because of my IDE's default browser.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts 2.1 error message breaks page html formatting