Advertisement

06.06.2007 at 07:25AM PDT, ID: 22616387
[x]
Attachment Details

struts problem: pulldown menu

Asked by ayeen in Jakarta Struts, Java Server Pages (JSP), J2EE

Tags: struts, bean

hi all,
i'm just wondering if someone could help me with my struts pulldown menu problem.... i'm trying to convert my multibox to a pulldown menu... the user can only choose 1 driver...
thanks in advance!

- @


i have this multibox:

<logic:notEmpty name="processFilterFormBean" property="driverlist">
<logic:iterate name="processFilterFormBean" property="driverlist" id="driver">             
<tr>
      <td>
      <html:multibox name="driver" property="selecteddriverid">
            <bean:write name="driver" property="drivername"/>
      </html:multibox>
      <bean:write name="driver" property="drivername" />
      </td>
</tr>
</logic:iterate>
</logic:notEmpty>

that i want to make into a pulldown menu...


i've tried doing  the several <html:select>/<html:optionsCollection> tutorials i found online but i can't make it work and i would really appreciate your help guys...




---------------------------------------
here's what my struts-config.xml looks:
---------------------------------------

<action-mappings>
      <action path="/maintenance" type="com.webtest.resources.MaintenanceAction" name="processFilterFormBean" scope="request">
            <forward name="start" path = "/WEB-INF/pages/Maintenance.jsp"/>            
      </action>
</action-mappings>


<form-beans>
      <form-bean name="processFilterFormBean" type="com.webtest.resources.ProcessFilterFormBean">
      </form-bean>
</form-beans>      





---------------------------------------
here's my Form Bean:
---------------------------------------

public class ProcessFilterFormBean extends ActionForm {
      private Collection driverlist;
      private String[] selecteddriverid;

      private String driverid = "";
      private String drivername = "";



      // for driver list
      public void setDriverlist(Collection driverlist){
            this.driverlist = driverlist;            
      }

      public Collection getDriverlist(){
            return driverlist;
      }
      
      public String[] getSelecteddriverid(){
            return selecteddriverid;
      }
      
      public void setSelecteddriverid(String[] driverid){
            this.selecteddriverid = driverid;
      }      
      
      
      
      public void reset(ActionMapping mapping, HttpServletRequest request) {
            driverlist = new ArrayList();

      }

      public ActionErrors validate(
            ActionMapping mapping,
            HttpServletRequest request) {

            ActionErrors errors = new ActionErrors();
            return errors;

      }

}




---------------------------------------
here's my action class:
---------------------------------------

public class MaintenanceAction extends Action {

      public ActionForward execute(
            ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response)
            throws Exception {
                        
            ActionErrors errors = new ActionErrors();
            ActionForward forward = new ActionForward();

            ProcessFilterFormBean pfbean = (ProcessFilterFormBean) form;

            //call the DB
            SimulateDB simulateDB = new SimulateDB();
            pfbean.setDriverlist(simulateDB.getDriverlist(request.getSession()));            

            
            return (mapping.findForward("start"));

      }
}





---------------------------------------
here is my SimulateDB:
---------------------------------------
public class SimulateDB {

    private String drivername;
      private Collection dlist;
      private String result;

    private void init(HttpSession session) {
            
            //test data while DB is not  yet ready
            dlist = new ArrayList();
            dlist.add(new Driver("CCMP",  "Suspense",                   false));
            dlist.add(new Driver("EXALL", "Exclusion Indicator",             false));
            dlist.add(new Driver("EXSUB", "Exclusion Subscriber",             false));
            dlist.add(new Driver("MAIL",  "Mail to Option",             false));
            dlist.add(new Driver("PTD",   "Paid to Date",                   false));
            dlist.add(new Driver("SUSP",  "Suspense Days",                   false));
            dlist.add(new Driver("TERM",  "Termination Days",             false));            
            dlist.add(new Driver("OTHER", "Other",                         false));            
            session.setAttribute("driverDB", dlist);
            
            //another set..trying LabelValueBean
            ArrayList dlist2 = new ArrayList();
      
            dlist2.add(new org.apache.struts.util.LabelValueBean("CCMP",  "Suspense"));
            dlist2.add(new org.apache.struts.util.LabelValueBean("EXALL", "Exclusion Indicator"));
            dlist2.add(new org.apache.struts.util.LabelValueBean("EXSUB", "Exclusion Subscriber"));            
            dlist2.add(new org.apache.struts.util.LabelValueBean("MAIL",  "Mail to Option"));            
            dlist2.add(new org.apache.struts.util.LabelValueBean("PTD",   "Paid to Date"));
            dlist2.add(new org.apache.struts.util.LabelValueBean("SUSP",  "Suspense Days"));
            dlist2.add(new org.apache.struts.util.LabelValueBean("TERM",  "Termination Days"));            
            dlist2.add(new org.apache.struts.util.LabelValueBean("OTHER", "Other"));
            session.setAttribute("fulfillment_drivers", dlist2);

    }

   
    private void loadData(HttpSession session) {
           dlist = (Collection) session.getAttribute("driverDB");
        if (dlist == null || elist == null)
            init(session);
    }

    public String getDrivername(HttpSession session) {
        loadData(session);
        return drivername;

    }
          
   public void loadDriverlist(HttpSession session){
      //put them in our session
      dlist = (Collection) session.getAttribute("driverDB");
      if (dlist == null)
            init(session);
   }
   public Collection getDriverlist(HttpSession session) {
      loadDriverlist(session);
      return dlist;
   }      
      
}

---------------------------------------
here's my Driver class:
---------------------------------------

public class Driver {
      
      private String driverid = "";
      private String[] selecteddriverid;
      private String drivername = "";

      
      public Driver(){}
      
      public Driver(String driverid, String drivername, boolean checked){
            this.driverid = driverid;
            this.drivername = drivername;
      }
      
      public void setDriverid(String driverid){
      this.driverid = driverid;
      }
      public String getDriverid(){
            return driverid;
      }      
            
      public String[] getSelecteddriverid(){
            return selecteddriverid;
      }
      
      public void setSelecteddriverid(String[] driverid){
            this.selecteddriverid = driverid;
      }
      
      public void setDrivername(String drivername){
            this.drivername = drivername;
      }      

      public String getDrivername(){
            return drivername;
      }

}Start Free Trial
[+][-]06.09.2007 at 01:54PM PDT, ID: 19249848

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.11.2007 at 08:11AM PDT, ID: 19258724

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.11.2007 at 01:46PM PDT, ID: 19261686

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.12.2007 at 10:42AM PDT, ID: 19268216

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.12.2007 at 10:51AM PDT, ID: 19268281

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.12.2007 at 12:23PM PDT, ID: 19269072

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.12.2007 at 12:58PM PDT, ID: 19269316

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Jakarta Struts, Java Server Pages (JSP), J2EE
Tags: struts, bean
Sign Up Now!
Solution Provided By: Jathrek
Participating Experts: 1
Solution Grade: B
 
 
[+][-]06.13.2007 at 08:14AM PDT, ID: 19275266

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.13.2007 at 10:12AM PDT, ID: 19276202

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.13.2007 at 11:16AM PDT, ID: 19276711

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.13.2007 at 11:32AM PDT, ID: 19276862

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.13.2007 at 12:06PM PDT, ID: 19277131

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32