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

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;"/>

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

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?

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

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?

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

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'}"

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

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" />

>
> 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: [hidden email]> For additional commands, e-mail: [hidden email]>
>

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

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

or the

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'}"

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

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 <Dale@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

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.

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

or the

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.

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

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?

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?

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?