Santosh Kumar Panda wrote the following on 11/22/2004 5:07 AM:

I have been facing problems populating drop-downs using dummy stub classes .I have used a function to populate the page containing the drop-down and thrown the Action Form type object into the session.

Well you didn't create a function(method) for populating the dropdowns. You created some kind of method that is returning an ActionForm. Create a method called populate(..) that returns a Collection in your Action go do what you want and call that from your action methods. (If you arne't using a DispatchAction then just put the populate method in a base class or else maybe in some Helper class). I describe more here
http://www.reumann.net/struts/articles/request_lists.jsp


<no other comments from me below>




Now how do I retrieve the values on to my jsp screen. Here is the code snippet..



*_Action Class_*:

………………



form = populate(request, iFlag);

session.setAttribute("com.itest.web.form.SelectionForm", form);



………………….



…………………..

*public* ActionForm populate(HttpServletRequest request)

      {



                  SelectionForm form = *new* SelectionForm();

                  ArrayList arlproject = ProjectData.getProjects();

                  ListIterator iter = arlproject.listIterator();

                  *while* (iter.hasNext())

                  {

                        Project proj = (Project) iter.next();



System.out.println("++++++++++++++++" + (String)proj.getProjectcode());

                        form.setProjects((String)proj.getProjectcode());

                  }

                  *return* form;

            }



*_SelectionForm.java_*

*_ _*

*public* *void* setProjects(String strProject) {



            System.out.println("rrrrrrrrrrrrrrrrrr");

            String strKey="proj"+index;

            System.out.println("rrrrrrrrrrrrrrrrrr"+strKey);

            *if* (*this*.htbSelect.containsKey(strKey))

            {

            index++;

            strKey="proj"+index;

            }

                  //this.htbSelect.remove("proj");

            *this*.htbSelect.put(strKey,strProject);

            System.out.println("rrrrrrrrrrrrrrrrrr"+index);

            System.out.println("iiiiiiiiiiiiii"+htbSelect.get(strKey));



      }



      *public* ArrayList getProjects() {

                  ArrayList arlProject=*new* ArrayList();

                  System.out.println("111111111111111111111111111"+index);

                  *for*(*int* i=0;i<index;i++)

                  {

                  String strKey="proj"+i;

                  String proj=(String)*this*.htbSelect.get(strKey);

                  arlProject.add(proj);

                  }

            *return*(arlProject);

            }

*_ _*



------------------------------------------------------------------------

/*/Regrads/*/



/*/Santosh Kumar Panda/*/

/*/Software Engineer/*/

/*/HTDM(extn.2680)/*/







--
Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to