tags:

views:

13

answers:

2

In My struts2 application i have a struts2 tag checkboxlist something like this

 <s:checkboxlist name="yourSelect" label="Are You Inteterested In"    
       list="communityList" value="defaultSelect" /> 

i added the list elements in my action class constuctor

view plaincopy to clipboardprint?

 public CustomerAction()  
      {  
         communityList = new ArrayList<String>();  
            communityList.add("WebSpere Consultuing");  
          communityList.add("Portal Consulting");  
          communityList.add("SOA/BPM Consulting");  
            communityList.add("Content Management");  
    }  

public CustomerAction() { communityList = new ArrayList(); communityList.add("WebSpere Consultuing"); communityList.add("Portal Consulting"); communityList.add("SOA/BPM Consulting"); communityList.add("Content Management"); }

and i can very well display it on the jsp page ,

But the problem is when i call the jsp page in the web.xml

<welcome-file-list>
<welcome-file>/pages/Customer.jsp</welcome-file>
</welcome-file-list>

list is not populating , when i request the action name from the struts.xml of the Class whose constructor has the list values then the list is populating

how do i call the action name from the web.xml as a welcome-list-file instead of typing the action name at the url .....

A: 

You could create a new welcome jsp or html file with this in its <head>:

<meta http-equiv="Refresh" CONTENT="0; URL = /project/MyAction.action"/>

This will invoke your Struts2 action, which will handle populating the ArrayList and forwarding you to your real welcome page.

This thread has some other tips that may work as well.

Pat
Hi Thanks for the answer its working fine ,now i can call the action class in the url to load the checkboxlist values ,but if i call the action class to render the jsp page ,The is displaying along with the validation . Actually the validation should appear after i press the submit button in the page . not at the input time .So How can i solve this ?
jyo
You could create a method in your action class with a name like prep() that takes care of rendering the jsp, and then exclude prep() from your validation. The excludeMethod parameter does this in the interceptor stack definition: http://struts.apache.org/2.x/docs/interceptors.html#Interceptors-MethodFiltering
Pat
A: 

Create a simple JSP with an redirect.

<% response.sendRedirect("myaction.action"); %>
jogep