File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes label and style sheet in struts 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "label and style sheet in struts 2" Watch "label and style sheet in struts 2" New topic

label and style sheet in struts 2

hani Ibrahim
Ranch Hand

Joined: Sep 06, 2006
Posts: 182
Dear all,
i have 2 questions:
1)I want to separate "Enter your Name" in <td> and textFiled in other <td>
when i do that these 2 td arent appear in the same vertical alignment.
the first one in top and other in bottom i dont know why that happened???
im forced to do like this:
<s:textfield label="Enter your Name" value="" required="true" name="userBean.userName"></s:textfield>

but this option doesnt allow me to give label style sheet and the text field has another style sheet.
2)i build a cascade style sheet but i think it still not taken
please if any body give me tutorial or link for tutorial how to use custom cascade style sheet for using it to Struts2 please
Indrayani Bhoir

Joined: Dec 02, 2002
Posts: 21
You can use <s:text name="" cssStyle="width:125px;"></s:text> tag to display your label and add required css style in cssStyle attribute.
hani Ibrahim
Ranch Hand

Joined: Sep 06, 2006
Posts: 182
what i want something to use cascade style.css:

<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/style.css"/>

<s:textfield cssClass="" cssStyle="labelStyle" label="Enter your name" ></s:textfield>

As i see :1)the style wasnt affect.
2)even if it gives the result how can i separate the style of label from the style of textfield !!!.

please consider point 1 more important to me please.
Indrayani Bhoir

Joined: Dec 02, 2002
Posts: 21

may be seprating your lable and textfield will help you

<td><s:text name="text1" value="Enter your name" cssStyle="labelStyle"></s:text></td>
<td><s:textfield cssStyle="textStyle" name="userBean.userName"></s:textfield></td>
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you follow Indu's suggestion above, you must also specify theme="simple" either at the form level or the element level.

Consultant, Sima Solutions
hani Ibrahim
Ranch Hand

Joined: Sep 06, 2006
Posts: 182
This is not work:
<s:text name="text1" value="Enter your name" cssStyle="labelStyle"></s:text>

because <s:text> tag doesnt take value or cssStyle :
javax.servlet.ServletException: org.apache.jasper.JasperException: /login.jsp(44,0) PWC6131: Attribute value invalid for tag text according to TLD
it just tame:id and name so still we have problrm!
guntur reddy

Joined: Jan 23, 2011
Posts: 9
please help me sir
ex :<s:textfield name="first name" label="First Name" /> in this example how can i separate textfield and label .please send a one sample example . i am the stating stage of this program

Thanks sir
kaleeswaran Gounder

Joined: Jun 07, 2011
Posts: 4
I am also having same problem....Help me..

Manuel Schenkhuizen

Joined: Apr 20, 2011
Posts: 14
First you need a file name in your classpath
Second write struts.ui.theme=css_xhtml.
Third use cssClass attribute in your tag.
I agree. Here's the link:
subject: label and style sheet in struts 2
It's not a secret anymore!