Where to put the code for filling an ArrayList

2002-06-03 Thread hans albers

Hi there

I want a dropdown-box filled by a bean.

I fill the Arrraylist inside the jsp as you can see, but I don't
want to have this code in the jsp because the data later comes
from a database.
Where and how do I have to write this code (a...b) for the list be
accessed by the show.jsp?
In the showForm.java or showAction.java or in the Action.java of the
page before the show.jsp?

In my show.jsp:
<% //a
  java.util.ArrayList list = new java.util.ArrayList();
  list.add(new LabelValueBean("Art1", "a1"));
  list.add(new LabelValueBean("Art2", "a2"));
  list.add(new LabelValueBean("Art3", "a3"));
  session.setAttribute("my_list",list);
  // b
%>


  

  

_
Testen Sie MSN Messenger für Ihren Online-Chat mit Freunden: 
http://messenger.msn.com


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Where to put the code for filling an ArrayList

2002-06-03 Thread Anders Rosén

As a custom tag? I do this in one of my applications, when populating
selects from a table in a database.

<%@ taglib uri="/WEB-INF/myTagLib.tld" prefix="custom" %>




   


You need to create the java class (subclassing TagSupport) implementing
the doStartTag() and optionally doEndTag() methods. Create the ArrayList
object and put it somewhere convinient, for example as an attribute in
the request object. You also need to define the new tag in a tld-file.

Regards,
/Anders

-Ursprungligt meddelande-
Från: hans albers [mailto:[EMAIL PROTECTED]] 
Skickat: den 3 juni 2002 08:56
Till: [EMAIL PROTECTED]
Ämne: Where to put the code for filling an ArrayList


Hi there

I want a dropdown-box filled by a bean.

I fill the Arrraylist inside the jsp as you can see, but I don't want to
have this code in the jsp because the data later comes from a database.
Where and how do I have to write this code (a...b) for the list be
accessed by the show.jsp? In the showForm.java or showAction.java or in
the Action.java of the page before the show.jsp?

In my show.jsp:
<% //a
  java.util.ArrayList list = new java.util.ArrayList();
  list.add(new LabelValueBean("Art1", "a1"));
  list.add(new LabelValueBean("Art2", "a2"));
  list.add(new LabelValueBean("Art3", "a3"));
  session.setAttribute("my_list",list);
  // b
%>


  

  

_
Testen Sie MSN Messenger für Ihren Online-Chat mit Freunden: 
http://messenger.msn.com


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



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