You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Hubert Hers <in...@huberthers.com> on 2007/07/05 22:59:02 UTC

How to control the display of Struts2 tags like s:textfield

Hi,

Could anyone tell me how to use CSS styles in Struts2 for controlling the
display of labels, input elements, buttons etc. (s:textfield, s:button,
...)?
I can control the display of the key attribute using cssStyle or cssClass,
but did not find a way to do the same with the tags:
    <s:textfield key="username" cssStyle="color:blue;"/>

Thanks, Hubert




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to control the display of Struts2 tags like s:textfield

Posted by yitzle <yi...@users.sourceforge.net>.
Consider wrapping it in a <span class="blah"> tag...

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to control the display of Struts2 tags like s:textfield

Posted by RobinCamus <rc...@docsea.com>.
You can write a new Tag extending TextFieldTag to implement your own
attributes.
or
You can use the theme "simple" on your textfield so you can write the label
directly in html
<TR>
<TD>
<LABEL style="color: green" ....>
</TD>
<TD>
<s:textfield ....>
</TD
</TR>



TonyD wrote:
> 
> I'am using the "qxhtml" theme in my form.
> 
> the output generated is:
> 
> <TR>
>       <TD vAlign=top align=right></TD>
>       <TD vAlign=top align=left>
>        <INPUT id=myckb 
>                  style="COLOR: red" type=checkbox value=true name=myckb> 
>        <INPUT type=hidden value=true name=__checkbox_myckb> 
>        <LABEL class=checkboxLabel for=myckb>RED</LABEL> 
>        </TD>
> </TR>
> 
> The Style doesn't effect the label text, I supposed that:
>  
> <LABEL style="COLOR: red" class=checkboxLabel for=myckb>RED</LABEL> 
> 
> was what I wanted to have, how could I obtain that?
> 
> Thanks in advance.
> 
>  
> 
> 
> DNewfield wrote:
>> 
>> TonyD wrote:
>>> First of all, in my company, I'am representing all my colleagues that
>>> have
>>> problems with structs.
>> 
>> The tool is called Struts.  No 'c'.
>> 
>>> If I have a form with only one structs tag:
>>> 
>>> <s:checkbox cssStyle="color:red" id="myckb" name="myckb" label="RED"
>>> value="true"/>
>>> 
>>> and if the syntax of this instruction is correct, I should see a
>>> checkbox
>>> with a red label checked.
>> 
>> Nothing in this tag is setting the color of the label.  You're setting 
>> the text of the label to read "RED", and (hopefully) the style attribute 
>> of the checkbox to be "color:red".
>> 
>>> What does HTML mean? I know how setting colors with HTML and it works.
>>> The problem is structs.
>> 
>> What html does executing this .jsp produce?  Either it produces the html 
>> you think it generates, and IE is not displaying this in the way you 
>> expect, or it does not produce the html you want it to, and you should 
>> figure out why.
>> 
>> (hint:  In IE, try "view source" on the generated page.)
>> 
>> Have you tried the suggestions offered earlier?  For example, did you 
>> try cssStyle="%{'color:red'}" ?
>> 
>> What theme is this using?  Do you have a theme attribute on the s:form 
>> tag?  If not, do you have a struts.ui.theme setting anywhere?
>> 
>> -Dale
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-control-the-display-of-Struts2-tags-like-s%3Atextfield-tf4032263.html#a11685968
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to control the display of Struts2 tags like s:textfield

Posted by TonyD <an...@eunics.it>.
I'am using the "qxhtml" theme in my form.

the output generated is:

<TR>
      <TD vAlign=top align=right></TD>
      <TD vAlign=top align=left>
       <INPUT id=myckb 
                 style="COLOR: red" type=checkbox value=true name=myckb> 
       <INPUT type=hidden value=true name=__checkbox_myckb> 
       <LABEL class=checkboxLabel for=myckb>RED</LABEL> 
       </TD>
</TR>

The Style doesn't effect the label text, I supposed that:
 
<LABEL style="COLOR: red" class=checkboxLabel for=myckb>RED</LABEL> 

was what I wanted to have, how could I obtain that?

Thanks in advance.

 


DNewfield wrote:
> 
> TonyD wrote:
>> First of all, in my company, I'am representing all my colleagues that
>> have
>> problems with structs.
> 
> The tool is called Struts.  No 'c'.
> 
>> If I have a form with only one structs tag:
>> 
>> <s:checkbox cssStyle="color:red" id="myckb" name="myckb" label="RED"
>> value="true"/>
>> 
>> and if the syntax of this instruction is correct, I should see a checkbox
>> with a red label checked.
> 
> Nothing in this tag is setting the color of the label.  You're setting 
> the text of the label to read "RED", and (hopefully) the style attribute 
> of the checkbox to be "color:red".
> 
>> What does HTML mean? I know how setting colors with HTML and it works.
>> The problem is structs.
> 
> What html does executing this .jsp produce?  Either it produces the html 
> you think it generates, and IE is not displaying this in the way you 
> expect, or it does not produce the html you want it to, and you should 
> figure out why.
> 
> (hint:  In IE, try "view source" on the generated page.)
> 
> Have you tried the suggestions offered earlier?  For example, did you 
> try cssStyle="%{'color:red'}" ?
> 
> What theme is this using?  Do you have a theme attribute on the s:form 
> tag?  If not, do you have a struts.ui.theme setting anywhere?
> 
> -Dale
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-control-the-display-of-Struts2-tags-like-s%3Atextfield-tf4032263.html#a11557206
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to control the display of Struts2 tags like s:textfield

Posted by Dale Newfield <Da...@Newfield.org>.
TonyD wrote:
> First of all, in my company, I'am representing all my colleagues that have
> problems with structs.

The tool is called Struts.  No 'c'.

> If I have a form with only one structs tag:
> 
> <s:checkbox cssStyle="color:red" id="myckb" name="myckb" label="RED"
> value="true"/>
> 
> and if the syntax of this instruction is correct, I should see a checkbox
> with a red label checked.

Nothing in this tag is setting the color of the label.  You're setting 
the text of the label to read "RED", and (hopefully) the style attribute 
of the checkbox to be "color:red".

> What does HTML mean? I know how setting colors with HTML and it works.
> The problem is structs.

What html does executing this .jsp produce?  Either it produces the html 
you think it generates, and IE is not displaying this in the way you 
expect, or it does not produce the html you want it to, and you should 
figure out why.

(hint:  In IE, try "view source" on the generated page.)

Have you tried the suggestions offered earlier?  For example, did you 
try cssStyle="%{'color:red'}" ?

What theme is this using?  Do you have a theme attribute on the s:form 
tag?  If not, do you have a struts.ui.theme setting anywhere?

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to control the display of Struts2 tags like s:textfield

Posted by TonyD <an...@eunics.it>.
First of all, in my company, I'am representing all my colleagues that have
problems with structs. 
Our development tool is Eclipse 3.2.2 and our browser is Microsoft Internet
Explorer.

If I have a form with only one structs tag:

<s:checkbox cssStyle="color:red" id="myckb" name="myckb" label="RED"
value="true"/>

and if the syntax of this instruction is correct, I should see a checkbox
with a red label checked.
What does HTML mean? I know how setting colors with HTML and it works.
The problem is structs.


DNewfield wrote:
> 
> TonyD wrote:
>> I tried your suggestions but still the ccsStyle doesn't change the
>> checkbox
>> label color.
> You're right--cssStyle results in a style attribute on the checkbox, not 
> on the label.
> 
>> My checkbox is created using an interator and is display into a table.
>> I tried changing the <td Style="color:green"> or the <tr> style but
>> nothing
>> changes.
>> Please other suggestions! Thanks.
> 
> Capitalization matters.
> 
> It sounds like your problems have little to do with struts, but rather 
> trying to learn html.  There are plenty of free tutorials online.  I'd 
> suggest http://www.w3schools.com/default.asp as a starting point.  And 
> remember, different browsers work differently, so just because it works 
> somewhere doesn't mean it's "right."  The best bet to getting it to work 
> everywhere is to use mechanisms that have been standardized.
> 
> -Dale
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-control-the-display-of-Struts2-tags-like-s%3Atextfield-tf4032263.html#a11535826
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to control the display of Struts2 tags like s:textfield

Posted by Dale Newfield <Da...@Newfield.org>.
TonyD wrote:
> I tried your suggestions but still the ccsStyle doesn't change the checkbox
> label color.
You're right--cssStyle results in a style attribute on the checkbox, not 
on the label.

> My checkbox is created using an interator and is display into a table.
> I tried changing the <td Style="color:green"> or the <tr> style but nothing
> changes.
> Please other suggestions! Thanks.

Capitalization matters.

It sounds like your problems have little to do with struts, but rather 
trying to learn html.  There are plenty of free tutorials online.  I'd 
suggest http://www.w3schools.com/default.asp as a starting point.  And 
remember, different browsers work differently, so just because it works 
somewhere doesn't mean it's "right."  The best bet to getting it to work 
everywhere is to use mechanisms that have been standardized.

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to control the display of Struts2 tags like s:textfield

Posted by TonyD <an...@eunics.it>.
I tried your suggestions but still the ccsStyle doesn't change the checkbox
label color. 
My checkbox is created using an interator and is display into a table.
I tried changing the <td Style="color:green"> or the <tr> style but nothing
changes.
Please other suggestions! Thanks.


DNewfield wrote:
> 
> TonyD wrote:
>> I have the same problem with a checkbox tag, 
>> if a use the ccsStyle="color:Green" to change the label color to green, 
>> it doesn't work at run time and the label remains with a black color!
> 
> Is it generated by struts and ignored by the browser (if so, maybe 
> "Green" and "green" are not equivalent), or is it not getting to the 
> browser?  Maybe the attribute is being evaluated?  To find out if that's 
> the problem, try cssStyle="%{'color:green'}"
> 
> -Dale
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-control-the-display-of-Struts2-tags-like-s%3Atextfield-tf4032263.html#a11515732
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to control the display of Struts2 tags like s:textfield

Posted by TonyD <an...@eunics.it>.
I tried but doesn't work. 
However I'am using in my form a particular theme "qxhtml" for displaying
fields horizontaly in a table tag.
I cann't believe it's so hard to change a label color with struts!
Thanks for your reply.


Leena Borle wrote:
> 
> You can try this,
>   set the theme of your form to css_xhtml .
>   If you have any css classe, you can just call them within form elements
> like .e.g.
> <s:submit   action="ABC"  cssClass="buttons" />
> <s:textfield key="myText" labelposition="left" cssClass="textfield" />
> 
> Leena
> 
> On 7/9/07, Dale Newfield <Da...@newfield.org> wrote:
>>
>> TonyD wrote:
>> > I have the same problem with a checkbox tag,
>> > if a use the ccsStyle="color:Green" to change the label color to green,
>> > it doesn't work at run time and the label remains with a black color!
>>
>> Is it generated by struts and ignored by the browser (if so, maybe
>> "Green" and "green" are not equivalent), or is it not getting to the
>> browser?  Maybe the attribute is being evaluated?  To find out if that's
>> the problem, try cssStyle="%{'color:green'}"
>>
>> -Dale
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-control-the-display-of-Struts2-tags-like-s%3Atextfield-tf4032263.html#a11515870
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to control the display of Struts2 tags like s:textfield

Posted by Leena Borle <ls...@gmail.com>.
You can try this,
  set the theme of your form to css_xhtml .
  If you have any css classe, you can just call them within form elements
like .e.g.
<s:submit   action="ABC"  cssClass="buttons" />
<s:textfield key="myText" labelposition="left" cssClass="textfield" />

Leena

On 7/9/07, Dale Newfield <Da...@newfield.org> wrote:
>
> TonyD wrote:
> > I have the same problem with a checkbox tag,
> > if a use the ccsStyle="color:Green" to change the label color to green,
> > it doesn't work at run time and the label remains with a black color!
>
> Is it generated by struts and ignored by the browser (if so, maybe
> "Green" and "green" are not equivalent), or is it not getting to the
> browser?  Maybe the attribute is being evaluated?  To find out if that's
> the problem, try cssStyle="%{'color:green'}"
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: How to control the display of Struts2 tags like s:textfield

Posted by Dale Newfield <Da...@Newfield.org>.
TonyD wrote:
> I have the same problem with a checkbox tag, 
> if a use the ccsStyle="color:Green" to change the label color to green, 
> it doesn't work at run time and the label remains with a black color!

Is it generated by struts and ignored by the browser (if so, maybe 
"Green" and "green" are not equivalent), or is it not getting to the 
browser?  Maybe the attribute is being evaluated?  To find out if that's 
the problem, try cssStyle="%{'color:green'}"

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to control the display of Struts2 tags like s:textfield

Posted by TonyD <an...@eunics.it>.
I have the same problem with a checkbox tag, 
if a use the ccsStyle="color:Green" to change the label color to green, 
it doesn't work at run time and the label remains with a black color! 

It's a serious problem. I think Hubert Hers wrote for the same thing.

Could someone help us!

Thanks!


Laurie Harper wrote:
> 
> Hubert Hers wrote:
>> Hi,
>> 
>> Could anyone tell me how to use CSS styles in Struts2 for controlling the
>> display of labels, input elements, buttons etc. (s:textfield, s:button,
>> ....)?
>> I can control the display of the key attribute using cssStyle or
>> cssClass,
>> but did not find a way to do the same with the tags:
>>     <s:textfield key="username" cssStyle="color:blue;"/>
>> 
>> Thanks, Hubert
> 
> What exactly is the problem? cssStyle is a valid attribute for the 
> s:textfield tag. Are you saying the CSS you supply is not rendered? 
> Rendered but is having no effect? Or something else?
> 
> L.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-control-the-display-of-Struts2-tags-like-s%3Atextfield-tf4032263.html#a11500125
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to control the display of Struts2 tags like s:textfield

Posted by Laurie Harper <la...@holoweb.net>.
Hubert Hers wrote:
> Hi,
> 
> Could anyone tell me how to use CSS styles in Struts2 for controlling the
> display of labels, input elements, buttons etc. (s:textfield, s:button,
> ....)?
> I can control the display of the key attribute using cssStyle or cssClass,
> but did not find a way to do the same with the tags:
>     <s:textfield key="username" cssStyle="color:blue;"/>
> 
> Thanks, Hubert

What exactly is the problem? cssStyle is a valid attribute for the 
s:textfield tag. Are you saying the CSS you supply is not rendered? 
Rendered but is having no effect? Or something else?

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org