You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by carmi_cd <ca...@yahoo.com> on 2008/01/07 07:58:45 UTC

[S2] Form Select

i have a form select.. my problem is i dont know how can i get the selected
values in the form select box.

here is my code..

   <s:select name="selectedModules" value="%{edituser.modules.{moduleId}}"
          list="modules" listKey="moduleId" listValue="moduleName" 
            multiple="true" size="7"  />

it has multiple set to true..so it should return something like a list or
array..but if i try to 
retrieved it using this code..

        List selectedModules =getSelectedModules();     
        System.out.println("selected " + selectedModules.size());

i get a null pointer exception error.. how should i do it? 

thanks in advance..


-- 
View this message in context: http://www.nabble.com/-S2--Form-Select-tp14659864p14659864.html
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: [S2] Form Select

Posted by carmi_cd <ca...@yahoo.com>.
thank you so much..it solved the problem..


Laurie Harper wrote:
> 
> They need to be public for Struts to be able to call them... ;-)
> 
> carmi_cd wrote:
>> here is my getter and setter method for selectedModules
>> 
>>     private String[] getSelectedModules() {
>>         return selectedModules;
>>     }
>>     
>>     private void setSelectedModules(String[] value) {
>>        selectedModules=value;
>>     }    
>> 
>> 
>> 
>> 
>> Laurie Harper wrote:
>>> What do you getter and setter methods for the selectedModules property 
>>> look like? Remember, you need both for data to be passed in both
>>> directions.
>>>
>>> L.
>>>
>>>
>>> carmi_cd wrote:
>>>> hi ted..thanks.. i tried to retrieved selectedModules as an array of
>>>> String..
>>>> but it was not able to get the values..
>>>> here is my code..
>>>>
>>>>       String[] selectedModules =getSelectedModules();     
>>>>       System.out.println("selected " + selectedModules[0]);
>>>>
>>>> It printed the value of selected is null..when i selected values from
>>>> the
>>>> list.
>>>> i'm really new with S2, hope you could help me with this..thanks in
>>>> advance.
>>>>
>>>>
>>>>
>>>>
>>>> Ted Husted wrote:
>>>>> Hmmm, did you try selectedModules as an array of String?
>>>>>
>>>>> HTH, Ted
>>>>>  * <http://www.StrutsMentor.com/>
>>>>>
>>>>>
>>>>> On Jan 7, 2008 1:58 AM, carmi_cd <ca...@yahoo.com> wrote:
>>>>>> i have a form select.. my problem is i dont know how can i get the
>>>>>> selected
>>>>>> values in the form select box.
>>>>>>
>>>>>> here is my code..
>>>>>>
>>>>>>    <s:select name="selectedModules"
>>>>>> value="%{edituser.modules.{moduleId}}"
>>>>>>           list="modules" listKey="moduleId" listValue="moduleName"
>>>>>>             multiple="true" size="7"  />
>>>>>>
>>>>>> it has multiple set to true..so it should return something like a
>>>>>> list
>>>>>> or
>>>>>> array..but if i try to
>>>>>> retrieved it using this code..
>>>>>>
>>>>>>         List selectedModules =getSelectedModules();
>>>>>>         System.out.println("selected " + selectedModules.size());
>>>>>>
>>>>>> i get a null pointer exception error.. how should i do it?
>>>>>>
>>>>>> thanks in advance..
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>
>>>>>
>>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>> 
> 
> 
> ---------------------------------------------------------------------
> 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/-S2--Form-Select-tp14659864p14726058.html
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: [S2] Form Select

Posted by Laurie Harper <la...@holoweb.net>.
They need to be public for Struts to be able to call them... ;-)

carmi_cd wrote:
> here is my getter and setter method for selectedModules
> 
>     private String[] getSelectedModules() {
>         return selectedModules;
>     }
>     
>     private void setSelectedModules(String[] value) {
>        selectedModules=value;
>     }    
> 
> 
> 
> 
> Laurie Harper wrote:
>> What do you getter and setter methods for the selectedModules property 
>> look like? Remember, you need both for data to be passed in both
>> directions.
>>
>> L.
>>
>>
>> carmi_cd wrote:
>>> hi ted..thanks.. i tried to retrieved selectedModules as an array of
>>> String..
>>> but it was not able to get the values..
>>> here is my code..
>>>
>>>       String[] selectedModules =getSelectedModules();     
>>>       System.out.println("selected " + selectedModules[0]);
>>>
>>> It printed the value of selected is null..when i selected values from the
>>> list.
>>> i'm really new with S2, hope you could help me with this..thanks in
>>> advance.
>>>
>>>
>>>
>>>
>>> Ted Husted wrote:
>>>> Hmmm, did you try selectedModules as an array of String?
>>>>
>>>> HTH, Ted
>>>>  * <http://www.StrutsMentor.com/>
>>>>
>>>>
>>>> On Jan 7, 2008 1:58 AM, carmi_cd <ca...@yahoo.com> wrote:
>>>>> i have a form select.. my problem is i dont know how can i get the
>>>>> selected
>>>>> values in the form select box.
>>>>>
>>>>> here is my code..
>>>>>
>>>>>    <s:select name="selectedModules"
>>>>> value="%{edituser.modules.{moduleId}}"
>>>>>           list="modules" listKey="moduleId" listValue="moduleName"
>>>>>             multiple="true" size="7"  />
>>>>>
>>>>> it has multiple set to true..so it should return something like a list
>>>>> or
>>>>> array..but if i try to
>>>>> retrieved it using this code..
>>>>>
>>>>>         List selectedModules =getSelectedModules();
>>>>>         System.out.println("selected " + selectedModules.size());
>>>>>
>>>>> i get a null pointer exception error.. how should i do it?
>>>>>
>>>>> thanks in advance..
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
> 


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


Re: [S2] Form Select

Posted by carmi_cd <ca...@yahoo.com>.
here is my getter and setter method for selectedModules

    private String[] getSelectedModules() {
        return selectedModules;
    }
    
    private void setSelectedModules(String[] value) {
       selectedModules=value;
    }    




Laurie Harper wrote:
> 
> What do you getter and setter methods for the selectedModules property 
> look like? Remember, you need both for data to be passed in both
> directions.
> 
> L.
> 
> 
> carmi_cd wrote:
>> hi ted..thanks.. i tried to retrieved selectedModules as an array of
>> String..
>> but it was not able to get the values..
>> here is my code..
>> 
>>       String[] selectedModules =getSelectedModules();     
>>       System.out.println("selected " + selectedModules[0]);
>> 
>> It printed the value of selected is null..when i selected values from the
>> list.
>> i'm really new with S2, hope you could help me with this..thanks in
>> advance.
>> 
>> 
>> 
>> 
>> Ted Husted wrote:
>>> Hmmm, did you try selectedModules as an array of String?
>>>
>>> HTH, Ted
>>>  * <http://www.StrutsMentor.com/>
>>>
>>>
>>> On Jan 7, 2008 1:58 AM, carmi_cd <ca...@yahoo.com> wrote:
>>>> i have a form select.. my problem is i dont know how can i get the
>>>> selected
>>>> values in the form select box.
>>>>
>>>> here is my code..
>>>>
>>>>    <s:select name="selectedModules"
>>>> value="%{edituser.modules.{moduleId}}"
>>>>           list="modules" listKey="moduleId" listValue="moduleName"
>>>>             multiple="true" size="7"  />
>>>>
>>>> it has multiple set to true..so it should return something like a list
>>>> or
>>>> array..but if i try to
>>>> retrieved it using this code..
>>>>
>>>>         List selectedModules =getSelectedModules();
>>>>         System.out.println("selected " + selectedModules.size());
>>>>
>>>> i get a null pointer exception error.. how should i do it?
>>>>
>>>> thanks in advance..
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>> 
> 
> 
> ---------------------------------------------------------------------
> 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/-S2--Form-Select-tp14659864p14704456.html
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: [S2] Form Select

Posted by Laurie Harper <la...@holoweb.net>.
What do you getter and setter methods for the selectedModules property 
look like? Remember, you need both for data to be passed in both directions.

L.

carmi_cd wrote:
> hi ted..thanks.. i tried to retrieved selectedModules as an array of String..
> but it was not able to get the values..
> here is my code..
> 
>       String[] selectedModules =getSelectedModules();     
>       System.out.println("selected " + selectedModules[0]);
> 
> It printed the value of selected is null..when i selected values from the
> list.
> i'm really new with S2, hope you could help me with this..thanks in advance.
> 
> 
> 
> 
> Ted Husted wrote:
>> Hmmm, did you try selectedModules as an array of String?
>>
>> HTH, Ted
>>  * <http://www.StrutsMentor.com/>
>>
>>
>> On Jan 7, 2008 1:58 AM, carmi_cd <ca...@yahoo.com> wrote:
>>> i have a form select.. my problem is i dont know how can i get the
>>> selected
>>> values in the form select box.
>>>
>>> here is my code..
>>>
>>>    <s:select name="selectedModules"
>>> value="%{edituser.modules.{moduleId}}"
>>>           list="modules" listKey="moduleId" listValue="moduleName"
>>>             multiple="true" size="7"  />
>>>
>>> it has multiple set to true..so it should return something like a list or
>>> array..but if i try to
>>> retrieved it using this code..
>>>
>>>         List selectedModules =getSelectedModules();
>>>         System.out.println("selected " + selectedModules.size());
>>>
>>> i get a null pointer exception error.. how should i do it?
>>>
>>> thanks in advance..
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
> 


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


Re: [S2] Form Select

Posted by carmi_cd <ca...@yahoo.com>.
hi ted..thanks.. i tried to retrieved selectedModules as an array of String..
but it was not able to get the values..
here is my code..

      String[] selectedModules =getSelectedModules();     
      System.out.println("selected " + selectedModules[0]);

It printed the value of selected is null..when i selected values from the
list.
i'm really new with S2, hope you could help me with this..thanks in advance.




Ted Husted wrote:
> 
> Hmmm, did you try selectedModules as an array of String?
> 
> HTH, Ted
>  * <http://www.StrutsMentor.com/>
> 
> 
> On Jan 7, 2008 1:58 AM, carmi_cd <ca...@yahoo.com> wrote:
>>
>> i have a form select.. my problem is i dont know how can i get the
>> selected
>> values in the form select box.
>>
>> here is my code..
>>
>>    <s:select name="selectedModules"
>> value="%{edituser.modules.{moduleId}}"
>>           list="modules" listKey="moduleId" listValue="moduleName"
>>             multiple="true" size="7"  />
>>
>> it has multiple set to true..so it should return something like a list or
>> array..but if i try to
>> retrieved it using this code..
>>
>>         List selectedModules =getSelectedModules();
>>         System.out.println("selected " + selectedModules.size());
>>
>> i get a null pointer exception error.. how should i do it?
>>
>> thanks in advance..
> 
> ---------------------------------------------------------------------
> 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/-S2--Form-Select-tp14659864p14680961.html
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: [S2] Form Select

Posted by Ted Husted <hu...@apache.org>.
Hmmm, did you try selectedModules as an array of String?

HTH, Ted
 * <http://www.StrutsMentor.com/>


On Jan 7, 2008 1:58 AM, carmi_cd <ca...@yahoo.com> wrote:
>
> i have a form select.. my problem is i dont know how can i get the selected
> values in the form select box.
>
> here is my code..
>
>    <s:select name="selectedModules" value="%{edituser.modules.{moduleId}}"
>           list="modules" listKey="moduleId" listValue="moduleName"
>             multiple="true" size="7"  />
>
> it has multiple set to true..so it should return something like a list or
> array..but if i try to
> retrieved it using this code..
>
>         List selectedModules =getSelectedModules();
>         System.out.println("selected " + selectedModules.size());
>
> i get a null pointer exception error.. how should i do it?
>
> thanks in advance..

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