You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Amine BADID <am...@yahoo.fr> on 2014/07/16 20:03:32 UTC

Please need help how to color the chosen elements

Hi All.
I want to know how to color the chosen  elements in a drop-down list ?
Thank you in advance.

Amine

Re: Please Need help how to select the chosen elements

Posted by Christoph Nenning <Ch...@lex-com.net>.
> Hi.
> Thank you Christoph for your reply.
> I tried to use this solution and it works.
> Only the selected items appear.
> But if I want to modify this list, I have only these elements not all !
> I hope that you have understand me.
> Thank you a lot in avance.
> 
> Best regards.
> 
> Amine.


Well, my last code sample was a copy pase error.
You can play with the attributes of select tag to find a solution that fit 
your needs.
At least you can flip name and list, but I think you need value, too.


Again, here is the link to documentation of select tag:
https://struts.apache.org/release/2.0.x/docs/select.html



regards,
Christoph








> 
> 
> 
> Le Jeudi 7 août 2014 9h21, Christoph Nenning <Christoph.Nenning@lex-
> com.net> a écrit :
> 
> 
> 
> > Thank you Christoph for your reply.
> > I tried to use it but I have more than one selected element. The 
> > solution above is for only one selected element, I think, no ?
> > 
> > I've many selected elements from the drop-down list.
> > Thank you a lot for your help.
> > Best regards.
> > Amine
> > 
> 
> 
> 
> 
> 
> 
> > I tried to use it but I have more than one selected element.
> How do you do that, with <select multiple="true" > ?
> 
> 
> In that case you can use struts tags like this:
> 
> <s:select
>      multiple="true"
>      name="allColors"
>      list="selectedColors"
> />
> 
> 
> 
> https://struts.apache.org/release/2.0.x/docs/select.html
> 
> 
> 
> regards,
> 
> Christoph
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> > 
> > 
> > Le Mercredi 6 août 2014 12h53, Christoph Nenning 
> > <Ch...@lex-com.net> a écrit :
> > 
> > 
> > 
> > > Thank you Christoph for reply
> > > In fact, when I choose these elements from the drop-down list, I 
> > > save them in the database.
> > > After I go to an other page And I do something next I return to the 
> > > first one but the éléments are not selected in the drop-down list 
> > > but they are realy savez in the database And I want that they apear 
> > > as selected items.
> > > Thank you
> > > 
> > > Regards
> > > 
> > > Amine
> > > 
> > 
> > 
> > Okay, now I understand your question (hopefully)
> > 
> > 
> > In plain HTML the selected <option> tag needs the attribute selected:
> > <option selected="selected">...</option> 
> > 
> > 
> > With struts2 tags you can do this:
> > 
> > <s:combobox
> >     name="color"
> >     list="colors"
> > />
> > 
> > Your action must provide getters for color and colors. While color is 
> the 
> > selected value from DB and colors is the whole list of items.
> > 
> > 
> > see:
> > https://struts.apache.org/release/2.0.x/docs/combobox.html
> > 
> > 
> > 
> > regards,
> > Christoph
> > 
> > 
> > 
> > This Email was scanned by Sophos Anti Virus
> 
> This Email was scanned by Sophos Anti Virus

This Email was scanned by Sophos Anti Virus

Re: Please Need help how to select the chosen elements

Posted by Amine BADID <am...@yahoo.fr>.
Hi.
Thank you Christoph for your reply.
I tried to use this solution and it works.
Only the selected items appear.
But if I want to modify this list, I have only these elements not all !
I hope that you have understand me.
Thank you a lot in avance.

Best regards.

Amine.



Le Jeudi 7 août 2014 9h21, Christoph Nenning <Ch...@lex-com.net> a écrit :
 


> Thank you Christoph for your reply.
> I tried to use it but I have more than one selected element. The 
> solution above is for only one selected element, I think, no ?
> 
> I've many selected elements from the drop-down list.
> Thank you a lot for your help.
> Best regards.
> Amine
> 






> I tried to use it but I have more than one selected element.
How do you do that, with <select multiple="true" > ?


In that case you can use struts tags like this:

<s:select
     multiple="true"
     name="allColors"
     list="selectedColors"
/>



https://struts.apache.org/release/2.0.x/docs/select.html



regards,

Christoph















> 
> 
> Le Mercredi 6 août 2014 12h53, Christoph Nenning 
> <Ch...@lex-com.net> a écrit :
> 
> 
> 
> > Thank you Christoph for reply
> > In fact, when I choose these elements from the drop-down list, I 
> > save them in the database.
> > After I go to an other page And I do something next I return to the 
> > first one but the éléments are not selected in the drop-down list 
> > but they are realy savez in the database And I want that they apear 
> > as selected items.
> > Thank you
> > 
> > Regards
> > 
> > Amine
> > 
> 
> 
> Okay, now I understand your question (hopefully)
> 
> 
> In plain HTML the selected <option> tag needs the attribute selected:
> <option selected="selected">...</option> 
> 
> 
> With struts2 tags you can do this:
> 
> <s:combobox
>     name="color"
>     list="colors"
> />
> 
> Your action must provide getters for color and colors. While color is 
the 
> selected value from DB and colors is the whole list of items.
> 
> 
> see:
> https://struts.apache.org/release/2.0.x/docs/combobox.html
> 
> 
> 
> regards,
> Christoph
> 
> 
> 
> This Email was scanned by Sophos Anti Virus

This Email was scanned by Sophos Anti Virus

Re: Please Need help how to select the chosen elements

Posted by Christoph Nenning <Ch...@lex-com.net>.
> Thank you Christoph for your reply.
> I tried to use it but I have more than one selected element. The 
> solution above is for only one selected element, I think, no ?
> 
> I've many selected elements from the drop-down list.
> Thank you a lot for your help.
> Best regards.
> Amine
> 






> I tried to use it but I have more than one selected element.
How do you do that, with <select multiple="true" > ?


In that case you can use struts tags like this:

 <s:select
     multiple="true"
     name="allColors"
     list="selectedColors"
 />



https://struts.apache.org/release/2.0.x/docs/select.html



regards,
Christoph















> 
> 
> Le Mercredi 6 août 2014 12h53, Christoph Nenning 
> <Ch...@lex-com.net> a écrit :
> 
> 
> 
> > Thank you Christoph for reply
> > In fact, when I choose these elements from the drop-down list, I 
> > save them in the database.
> > After I go to an other page And I do something next I return to the 
> > first one but the éléments are not selected in the drop-down list 
> > but they are realy savez in the database And I want that they apear 
> > as selected items.
> > Thank you
> > 
> > Regards
> > 
> > Amine
> > 
> 
> 
> Okay, now I understand your question (hopefully)
> 
> 
> In plain HTML the selected <option> tag needs the attribute selected:
> <option selected="selected">...</option> 
> 
> 
> With struts2 tags you can do this:
> 
> <s:combobox
>     name="color"
>     list="colors"
> />
> 
> Your action must provide getters for color and colors. While color is 
the 
> selected value from DB and colors is the whole list of items.
> 
> 
> see:
> https://struts.apache.org/release/2.0.x/docs/combobox.html
> 
> 
> 
> regards,
> Christoph
> 
> 
> 
> This Email was scanned by Sophos Anti Virus

This Email was scanned by Sophos Anti Virus

Re: Please Need help how to select the chosen elements

Posted by Amine BADID <am...@yahoo.fr>.
Thank you Christoph for your reply.
I tried to use it but I have more than one selected element. The solution above is for only one selected element, I think, no ?

I've many selected elements from the drop-down list.
Thank you a lot for your help.
Best regards.
Amine



Le Mercredi 6 août 2014 12h53, Christoph Nenning <Ch...@lex-com.net> a écrit :
 


> Thank you Christoph for reply
> In fact, when I choose these elements from the drop-down list, I 
> save them in the database.
> After I go to an other page And I do something next I return to the 
> first one but the éléments are not selected in the drop-down list 
> but they are realy savez in the database And I want that they apear 
> as selected items.
> Thank you
> 
> Regards
> 
> Amine
> 


Okay, now I understand your question (hopefully)


In plain HTML the selected <option> tag needs the attribute selected:
<option selected="selected">...</option> 


With struts2 tags you can do this:

<s:combobox
    name="color"
    list="colors"
/>

Your action must provide getters for color and colors. While color is the 
selected value from DB and colors is the whole list of items.


see:
https://struts.apache.org/release/2.0.x/docs/combobox.html



regards,
Christoph



This Email was scanned by Sophos Anti Virus

Re: Please Need help how to select the chosen elements

Posted by Christoph Nenning <Ch...@lex-com.net>.
> Thank you Christoph for reply
> In fact, when I choose these elements from the drop-down list, I 
> save them in the database.
> After I go to an other page And I do something next I return to the 
> first one but the éléments are not selected in the drop-down list 
> but they are realy savez in the database And I want that they apear 
> as selected items.
> Thank you
> 
> Regards
> 
> Amine
> 


Okay, now I understand your question (hopefully)


In plain HTML the selected <option> tag needs the attribute selected:
<option selected="selected">...</option> 


With struts2 tags you can do this:

<s:combobox
    name="color"
    list="colors"
 />

Your action must provide getters for color and colors. While color is the 
selected value from DB and colors is the whole list of items.


see:
https://struts.apache.org/release/2.0.x/docs/combobox.html


regards,
Christoph



This Email was scanned by Sophos Anti Virus

Re: Please Need help how to select the chosen elements

Posted by Amine BADID <am...@yahoo.fr>.
Thank you Christoph for reply
In fact, when I choose these elements from the drop-down list, I save them in the database.
After I go to an other page And I do something next I return to the first one but the éléments are not selected in the drop-down list but they are realy savez in the database And I want that they apear as selected items.
Thank you

Regards

Amine

Envoyé de mon iPhone

Le 6 août 2014 à 11:33, Christoph Nenning <Ch...@lex-com.net> a écrit :

>> Hi All.
>> I retry because I need help, please.
>>> 
>>> I want to know how to select (color) the chosen elements in a
>> drop-down list ?
>>> First, I've selected 3 elements from a drop-down list and I saved
>> them and I go to an other page.
>>> Next, I return to the page and I want to see these selected
>> elements but until now, They are not !
>>> I use java 6 and Struts 2.
>>> 
>>> Thank you in advance.
>>> 
>>> Amine
> 
> 
> 
> 
> This is the important point:
> 
>> and I go to an other page.
> 
> Your question is about "state". Which item the user chose on a previous 
> page is a form of application state. It is your job to maintain that 
> state.
> 
> Some of your options are:
> - include the selected item as parameter in all requests (GET and POST, 
> that means you have to add it all your links/redirects and forms as hidden 
> field, this is a "stateless" approach)
> - store it in http session (this is bad practice and causes other 
> problems)
> - store it in the browser, e.g. in a cookie or via some html5 
> local-storage api
> 
> 
> 
> regards,
> Christoph
> 
> This Email was scanned by Sophos Anti Virus
> 

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


Re: Please Need help how to select the chosen elements

Posted by Christoph Nenning <Ch...@lex-com.net>.
> Hi All.
> I retry because I need help, please.
> > 
> > I want to know how to select (color) the chosen elements in a 
> drop-down list ?
> > First, I've selected 3 elements from a drop-down list and I saved 
> them and I go to an other page.
> > Next, I return to the page and I want to see these selected 
> elements but until now, They are not !
> > I use java 6 and Struts 2.
> > 
> > Thank you in advance.
> > 
> > Amine




This is the important point:

> and I go to an other page.

Your question is about "state". Which item the user chose on a previous 
page is a form of application state. It is your job to maintain that 
state.

Some of your options are:
- include the selected item as parameter in all requests (GET and POST, 
that means you have to add it all your links/redirects and forms as hidden 
field, this is a "stateless" approach)
- store it in http session (this is bad practice and causes other 
problems)
- store it in the browser, e.g. in a cookie or via some html5 
local-storage api



regards,
Christoph

This Email was scanned by Sophos Anti Virus

Please Need help how to select the chosen elements

Posted by Amine BADID <am...@yahoo.fr>.
Hi All.
I retry because I need help, please.
> 
> I want to know how to select (color) the chosen elements in a drop-down list ?
> First, I've selected 3 elements from a drop-down list and I saved them and I go to an other page.
> Next, I return to the page and I want to see these selected elements but until now, They are not !
> I use java 6 and Struts 2.
> 
> Thank you in advance.
> 
> Amine

Re: Please need help how to color the chosen elements

Posted by Amine BADID <am...@yahoo.fr>.
Hi All.
I want to know how to select (color) the chosen elements in a drop-down list ?
First, I've selected 3 elements from a drop-down list and I saved them and I go to an other page.
Next, I return to the page and I want to see these selected elements but until now, They are not !
I use java 6 and Struts 2.

Thank you in advance.

Amine 


Le Mercredi 16 juillet 2014 20h10, Amine BADID <am...@yahoo.fr> a écrit :
 


Hi All.
I want to know how to color the chosen  elements in a drop-down list ?
Thank you in advance.

Amine