I have not written a Stripes formatter or TypeConverter yet. I know the
Stripes book goes through how to do it though so you can look there.

The each option in the select box appears to have a role_id, right? So what
you could do is have the property in the action bean be a list of the role
ids

List<Long> roles;

or

List<Long> rolesAsIds

include getters and setters and then in the event handler that your form
submits to, you can populate the roles set using the list of role IDs

Let me know if that helps.

Reuven

On Fri, Aug 17, 2012 at 10:27 AM, Vyman H <vyman.huig...@marlabs.com> wrote:

> Hi Reuven,****
>
> ** **
>
> Can u tell me how write formatter and TypeConverter    for Role****
>
> ** **
>
> ** **
>
> ** **
>
> *From:* Vyman H [mailto:vyman.huig...@marlabs.com]
> *Sent:* Friday, August 17, 2012 12:11 PM
>
> *To:* 'Stripes Users List'
> *Subject:* Re: [Stripes-users] stripes Question****
>
> ** **
>
> Hi Reuven,****
>
> ** **
>
> In the action bean I added the Set<Roles> to List****
>
> ** **
>
> *private* List<Roles>rolesavilable=*new* ArrayList<Roles>();****
>
>       ****
>
>       ****
>
>       *public* List<Roles> getRolesavilable() {****
>
>             *return* rolesavilable;****
>
>       }****
>
> ** **
>
>       *public* *void* setRolesavilable(List<Roles> rolesavilable) {****
>
>             *this*.rolesavilable = rolesavilable;****
>
> ** **
>
> @DefaultHandler****
>
>       *public* Resolution view() {****
>
>             rolesavilable=*new* 
> ArrayList<Roles>(roleservice.findAll());//adding
> set to list****
>
>             *return* *new* ForwardResolution("pages/Register.jsp");****
>
>       }****
>
> ** **
>
> ** **
>
> In jsp I have ****
>
> ** **
>
> <tr>****
>
> ** **
>
>                               <th><stripes:label for=*"rolesavilable"* />:
> </th>****
>
>                               <td><stripes:select name=*"rolesavilable"*
> multiple=*"true"* >****
>
>                                           <stripes:option  >--Roles--</
> stripes:option>****
>
>                                           <stripes:options-collection****
>
>                                                 collection=*"*
> ${actionBean.rolesavilable}*"* ****
>
>                                                 label=*"ROLES"* />****
>
>                                     </stripes:select> </td>****
>
>                         </tr>****
>
> ** **
>
> But in the save method of same action bean  I get null for “*rolesavilable
> *”****
>
> ** **
>
> @HandlesEvent("save")****
>
>       *public* Resolution save() {****
>
>             System.*out*.println("checking roles"+rolesavilable);//[] its
> null here****
>
>             service.saveUser(user);****
>
>             System.*out*.println("registered sussefuly");****
>
>             *return* *new* ForwardResolution("/index.jsp");****
>
>       }****
>
> ** **
>
> Am I going wrong in the stripes:select tag I hope…****
>
> ** **
>
> ** **
>
> ** **
>
> ** **
>
> ** **
>
> *From:* Reuven Gaisin [mailto:gais...@gmail.com]
> *Sent:* Friday, August 17, 2012 2:34 AM
> *To:* Stripes Users List
> *Subject:* Re: [Stripes-users] stripes Question****
>
> ** **
>
> Try changing the roles member variable in the Person class to a List
>
> Person
> {****
>
> private List<Roles> roles;
>
> public void setRoles(List<Roles> roles )
> {
>    this.roles = roles
> }
>
> public List<Roles> getRoles()
> {
>   return this.roles;
> } ****
>
>
> }
>
> Let me know if that works.
>
> Reuven****
>
> On Thu, Aug 16, 2012 at 5:38 AM, Vyman H <vyman.huig...@marlabs.com>
> wrote:****
>
> Can u tell me about stripes select collection****
>
>  ****
>
> How the value is assigned to ****
>
>  ****
>
> Person{****
>
> Set<Roles> roles;****
>
> …..with setter getter****
>
> }****
>
>  ****
>
> RegActionBean{****
>
> Person person;****
>
> … with setter getter;****
>
>  ****
>
> @Defaulthandler****
>
> {****
>
> Set<Roles>availableroles=rolesservice.findall()//I get the roles here****
>
> forwardResolution (JSP Page)****
>
>  ****
>
> }****
>
>  ****
>
> }****
>
>  ****
>
> Jsp page I have ****
>
>  ****
>
> <tr>****
>
>  ****
>
>                               <th><stripes:label for=*"person.roles"* />:
> </th>****
>
>                               <td><stripes:select name=*"person.roles"*  >
> ****
>
>                                           <stripes:option  formatType=*
> "Set"*>--Roles--</stripes:option>****
>
>                                           <stripes:options-collection****
>
>                                                 collection=*"*
> ${actionBean. availableroles }*"* value=*"role_id"*****
>
>                                                 label=*"ROLES"* />****
>
>                                     </stripes:select> </td>****
>
>                         </tr>****
>
>  ****
>
>  ****
>
> =*"*${actionBean. availableroles }*" I am getting Set<Roles>*****
>
>  ****
>
> But after the form is submitted and person is instantiated all the other
> properties are getting set  but except Person.roles…… it is null****
>
>  ****
>
> With thanks****
>
> Vyman ****
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users****
>
> ** **
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to