You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ashish Shrivastava <as...@gmail.com> on 2011/02/14 12:19:17 UTC

using select while migrating struts 1 to Struts 2

Hi,
Is it possible to use old (Struts 1) select with struts 2.

Struts 2 select has mandatory attribute "list".

SO if struts 1 select code needs to be migrated to struts 2 then list(array
list etc.) has to be in action  classes.

In case there are local list in JSP page in struts 1 which uses "option" to
display the list dynamically it has to be written in action class in struts
2.

The code for the current approach is below:



<s:select name="locSubTypeCategory" cssStyle="width:130px"
onChange="populateLocID(document.forms[3].subType.value,document.forms[3].locSubTypeCategory.options[document.forms[3].locSubTypeCategory.selectedIndex].value)"
disabled="<%=(!canCreateBus);%>">

<%

                if(busCust!=null && busCust.size()>0){

            for(int k=0;k<busCust.size();k++)

                {
locTypeInfo =(LocTypeInfo)busCust.get(k);

%>

<option value="<%=locTypeInfo.getLocSubType()%>">
<%=locTypeInfo.getLocSubTypeDesc()%> </option>

<%

}} else if(corpCust!=null && corpCust.size()>0){


for(int k=0;k<corpCust.size();k++)

              {

                 locTypeInfo =(LocTypeInfo)corpCust.get(k);

%>

<option value="<%=locTypeInfo.getLocSubType()%>">
<%=locTypeInfo.getLocSubTypeDesc()%> </option>

<%

}} else if(govCust!=null && govCust.size()>0){


for(int k=0;k<govCust.size();k++)

                {

                     locTypeInfo =(LocTypeInfo)govCust.get(k);

%>

<option value="<%=locTypeInfo.getLocSubType()%>">
<%=locTypeInfo.geLocSubTypeDesc()%> </option>

<% }} %>

</s:select>


For struts 2 we have to remove the option and add the list (busCust,
corpCust) to action class is there any way that we can use this code with
minimal change or without change.

Thanks & Regards
Ashish

Re: using select while migrating struts 1 to Struts 2

Posted by Dave Newton <da...@gmail.com>.
> Is it possible to use old (Struts 1) select with struts 2.

Short answer; not really.

> In case there are local list in JSP page in struts 1 which uses "option" to
> display the list dynamically it has to be written in action class in struts
> 2.
>
> The code for the current approach is below:
>
>
>
> <s:select name="locSubTypeCategory" cssStyle="width:130px"
> onChange="populateLocID(document.forms[3].subType.value,document.forms[3].locSubTypeCategory.options[document.forms[3].locSubTypeCategory.selectedIndex].value)"
> disabled="<%=(!canCreateBus);%>">
>
> <%
>
>                if(busCust!=null && busCust.size()>0){
>
>            for(int k=0;k<busCust.size();k++)
>
>                {
> locTypeInfo =(LocTypeInfo)busCust.get(k);
>
> %>
>
> <option value="<%=locTypeInfo.getLocSubType()%>">
> <%=locTypeInfo.getLocSubTypeDesc()%> </option>
>
> <%
>
> }} else if(corpCust!=null && corpCust.size()>0){
>
>
> for(int k=0;k<corpCust.size();k++)
>
>              {
>
>                 locTypeInfo =(LocTypeInfo)corpCust.get(k);
>
> %>
> [...]

This is all in your JSP?!

In any case, you'd probably be better off just not using S2 tags, or
doing the *right* thing, and fixing your JSP.

Dave

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