You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Fabian Richter <fr...@mtg.de> on 2013/12/11 12:39:34 UTC

Label CSS or referencing for addFieldError

Hi,

how can one add a specific css class/style of the label when 
instanciating like:

<s:textfield label="bla" name="commentField" id="commentField" />

I now had to change theme="simple" and add the css class to the <td> of 
the label but with that I can not reference it with the name when a 
fieldError occurred.

I have:

<s:label theme="simple" key="comment" for="commentField" />

and add an error with addFieldError("commentField", "no comment left") 
but that isnt working. The error is diplayed, but the label isnt red or 
got that exclamation mark in a triangle.

Any ideas how to solve that?

Thx!

Best,
Fabian


Antwort: Label CSS or referencing for addFieldError

Posted by Christoph Nenning <Ch...@lex-com.net>.
> Hi,
> 
> how can one add a specific css class/style of the label when 
> instanciating like:
> 
> <s:textfield label="bla" name="commentField" id="commentField" />
> 
> I now had to change theme="simple" and add the css class to the <td> of 
> the label but with that I can not reference it with the name when a 
> fieldError occurred.
> 
> I have:
> 
> <s:label theme="simple" key="comment" for="commentField" />
> 
> and add an error with addFieldError("commentField", "no comment left") 
> but that isnt working. The error is diplayed, but the label isnt red or 
> got that exclamation mark in a triangle.
> 
> Any ideas how to solve that?
> 
> Thx!
> 


You have several possibilities:
- Stick to simple theme and use <s:fieldError > to display validation 
errors. Not recommended as you cannot use some nice features of struts2

- Take another theme that is shipped with struts2 (or a plugin like 
jquery- or bootstrap-plugin), see how the generated html looks like and 
write your own css rules for that html

- Write your own theme

- Add <s:head /> to your html header, that includes css and js files 
required by struts2


regards,
Christoph

This Email was scanned by Sophos Anti Virus

Re: Label CSS or referencing for addFieldError

Posted by jayachandra B <ja...@gmail.com>.
I am using struts2 and hibernate3. I wan to store uploaded files in the
upload directory in the project folder. I want to store each uploaded file
path in the database using hibernate.

Can you help me out to achieve the above.


On Wed, Dec 11, 2013 at 5:25 PM, Christoph Nenning <
Christoph.Nenning@lex-com.net> wrote:

> > Can any one tell how to upload files to a particular directory in our
> > project.
> >
>
>
> You can set struts.multipart.saveDir in struts.xml
>
>
> https://struts.apache.org/release/2.0.x/docs/file-upload.html
>
>
> regards,
> Christoph
>
> This Email was scanned by Sophos Anti Virus
>



-- 
Thanks and Regards
Jayachandra

Re: Label CSS or referencing for addFieldError

Posted by Christoph Nenning <Ch...@lex-com.net>.
> Can any one tell how to upload files to a particular directory in our
> project.
> 


You can set struts.multipart.saveDir in struts.xml


https://struts.apache.org/release/2.0.x/docs/file-upload.html


regards,
Christoph

This Email was scanned by Sophos Anti Virus

Re: Label CSS or referencing for addFieldError

Posted by jayachandra B <ja...@gmail.com>.
HI,

Can any one tell how to upload files to a particular directory in our
project.


On Wed, Dec 11, 2013 at 5:09 PM, Fabian Richter <fr...@mtg.de> wrote:

> Hi,
>
> how can one add a specific css class/style of the label when instanciating
> like:
>
> <s:textfield label="bla" name="commentField" id="commentField" />
>
> I now had to change theme="simple" and add the css class to the <td> of
> the label but with that I can not reference it with the name when a
> fieldError occurred.
>
> I have:
>
> <s:label theme="simple" key="comment" for="commentField" />
>
> and add an error with addFieldError("commentField", "no comment left") but
> that isnt working. The error is diplayed, but the label isnt red or got
> that exclamation mark in a triangle.
>
> Any ideas how to solve that?
>
> Thx!
>
> Best,
> Fabian
>
>


-- 
Thanks and Regards
Jayachandra