Re: Need Help Fast

2002-09-26 Thread Michael Lee

Ive done this, everyone is overcomplicating it greatly...
Lookup.getData() gets an ArrayList of states.
This array list is loaded through an XML file that loads upon boot and puts
it in a static variable. This XML file can load it from itself or from the
database. It does all the .add() .add() .add() etc. This should NOT be done
in a jsp tag. Done once and pulled from static method like below. Nice and
simple.
Here's the JSP code.

<%  pageContext.setAttribute("allUnitedStates",
Lookup.getData(Constant.GLOBAL.UNITED_STATES)); %>



  
  



- Original Message -
From: "Hajratwala, Nayan (N.)" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Thursday, September 26, 2002 9:41 AM
Subject: RE: Need Help Fast


> Essentially, he is saying you can rewrite your doStartTag method to be
something like:
>
>   private List _states = null;
>
>   public int doStartTag() throws JspException {
>
> if (_states == null) {
>   _states = new java.util.ArrayList();
>   _states.add(new com.ubspw.cdd.common.LabelValueBean("-Select One-",
""));
>   _states.add(new com.ubspw.cdd.common.LabelValueBean("AK","AK"));
>   _states.add(new com.ubspw.cdd.common.LabelValueBean("AL","AL"));
>   _states.add(new com.ubspw.cdd.common.LabelValueBean("AR","AR"));
>   ...
>   ...
> }
>
> pageContext.setAttribute("selectStates", _states);
> return (EVAL_BODY_INCLUDE);
>   }
>
> this way, "states" will only be set up the first time doStartTag is
called.
>
>
> ---
> - Nayan Hajratwala
> - Chikli Consulting LLC
> - http://www.chikli.com
>
>
> -Original Message-
> From: Smith, Johnathan M. [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 26, 2002 9:14 AM
> To: 'Struts Users Mailing List'
> Cc: '[EMAIL PROTECTED]'
> Subject: RE: Need Help Fast
>
>
> Can you please send me a sample of a better way
>
> -Original Message-
> From: Ville Peurala [mailto:
> Sent: Thursday, September 26, 2002 8:26 AM
> To: Struts Users Mailing List
> Subject: RE: Need Help Fast
>
>
> Hello,
>
> One possible solution:
>
> Put the ArrayList in application context and put a check in doStartTag()'s
> beginning to determine whether the list of states can be found in
> application context.
>
> Instead of:
>
> pageContext.setAttribute("selectStates", states);
>
> Put it like this:
>
> pageContext.setAttribute("selectStates", states,
> PageContext.APPLICATION_SCOPE);
>
> And in the beginning of doStartTag():
>
> Object o = pageContext.getAttribute("selectStates",
> PageContext.APPLICATION_SCOPE);
> if (o == null) { ...do what your current code does...
> }
> else { ...do nothing... }
>
> But why do this in a tag at all? If your list of states never changes, you
> might as well initialize it in an init() method somewhere.
>
> T: Ville Peurala
>
>
> -Original Message-
> From: Smith, Johnathan M. [mailto:[EMAIL PROTECTED]]
> Sent: 26. syyskuuta 2002 15:13
> To: 'Struts Users Mailing List'
> Subject: Need Help Fast
>
>
> This is not really a struts question but I am using struts a maybe someone
> can help.  I system has allot of state dropdown's so I I made a tag for
the
> programmers to insert into the JSP pages.
>
> The Tag builds a ArrayList with the states in it and then saves the states
> as a attribute in the pageContext. But I don't know if this is the best
way
> to do it.  Is it anyway to tell this code only to run one time and then
stay
> in member?
>
> Below is my sample code: Please help me out
>
> public int doStartTag() throws JspException {
>
> java.util.ArrayList states = new java.util.ArrayList();
> states.add(new com.ubspw.cdd.common.LabelValueBean("-Select
> One-", ""));
> states.add(new com.ubspw.cdd.common.LabelValueBean("AK",
> "AK"));
> states.add(new com.ubspw.cdd.common.LabelValueBean("AL",
> "AL"));
> states.add(new com.ubspw.cdd.common.LabelValueBean("AR",
> "AR"));
> states.add(new com.ubspw.cdd.common.LabelValueBean("AZ",
> "AZ"));
> states.add(new com.ubspw.cdd.common.LabelValueBean("CA",
> "CA"));
> states.add(new com.ubspw.cdd.common.LabelValueBean("CO",
> "CO"));
> states.add(new com.ubspw.cdd.common.LabelValueBean("CT",
> "CT"));
> states.add(new com.ubspw.cdd.common.LabelValueBean("DC",
> "DC"));
> stat

RE: Need Help Fast

2002-09-26 Thread Hajratwala, Nayan (N.)

Essentially, he is saying you can rewrite your doStartTag method to be something like:

  private List _states = null;

  public int doStartTag() throws JspException {

if (_states == null) {
  _states = new java.util.ArrayList();
  _states.add(new com.ubspw.cdd.common.LabelValueBean("-Select One-", ""));
  _states.add(new com.ubspw.cdd.common.LabelValueBean("AK","AK"));
  _states.add(new com.ubspw.cdd.common.LabelValueBean("AL","AL"));
  _states.add(new com.ubspw.cdd.common.LabelValueBean("AR","AR"));
  ...
  ...
}

pageContext.setAttribute("selectStates", _states);
return (EVAL_BODY_INCLUDE);
  }  

this way, "states" will only be set up the first time doStartTag is called.


---
- Nayan Hajratwala
- Chikli Consulting LLC
- http://www.chikli.com


-Original Message-
From: Smith, Johnathan M. [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 26, 2002 9:14 AM
To: 'Struts Users Mailing List'
Cc: '[EMAIL PROTECTED]'
Subject: RE: Need Help Fast


Can you please send me a sample of a better way

-Original Message-----
From: Ville Peurala [mailto:
Sent: Thursday, September 26, 2002 8:26 AM
To: Struts Users Mailing List
Subject: RE: Need Help Fast


Hello,

One possible solution:

Put the ArrayList in application context and put a check in doStartTag()'s
beginning to determine whether the list of states can be found in
application context.

Instead of:

pageContext.setAttribute("selectStates", states);

Put it like this:

pageContext.setAttribute("selectStates", states,
PageContext.APPLICATION_SCOPE);

And in the beginning of doStartTag():

Object o = pageContext.getAttribute("selectStates",
PageContext.APPLICATION_SCOPE);
if (o == null) { ...do what your current code does...
}
else { ...do nothing... }

But why do this in a tag at all? If your list of states never changes, you
might as well initialize it in an init() method somewhere.

T: Ville Peurala


-Original Message-
From: Smith, Johnathan M. [mailto:[EMAIL PROTECTED]]
Sent: 26. syyskuuta 2002 15:13
To: 'Struts Users Mailing List'
Subject: Need Help Fast


This is not really a struts question but I am using struts a maybe someone
can help.  I system has allot of state dropdown's so I I made a tag for the
programmers to insert into the JSP pages. 

The Tag builds a ArrayList with the states in it and then saves the states
as a attribute in the pageContext. But I don't know if this is the best way
to do it.  Is it anyway to tell this code only to run one time and then stay
in member?

Below is my sample code: Please help me out

public int doStartTag() throws JspException {

java.util.ArrayList states = new java.util.ArrayList();
states.add(new com.ubspw.cdd.common.LabelValueBean("-Select
One-", ""));
states.add(new com.ubspw.cdd.common.LabelValueBean("AK",
"AK"));
states.add(new com.ubspw.cdd.common.LabelValueBean("AL",
"AL"));
states.add(new com.ubspw.cdd.common.LabelValueBean("AR",
"AR"));
states.add(new com.ubspw.cdd.common.LabelValueBean("AZ",
"AZ"));
states.add(new com.ubspw.cdd.common.LabelValueBean("CA",
"CA"));
states.add(new com.ubspw.cdd.common.LabelValueBean("CO",
"CO"));
states.add(new com.ubspw.cdd.common.LabelValueBean("CT",
"CT"));
states.add(new com.ubspw.cdd.common.LabelValueBean("DC",
"DC"));
states.add(new com.ubspw.cdd.common.LabelValueBean("DE",
"DE"));
states.add(new com.ubspw.cdd.common.LabelValueBean("FL",
"FL"));
states.add(new com.ubspw.cdd.common.LabelValueBean("GA",
"GA"));
states.add(new com.ubspw.cdd.common.LabelValueBean("HI",
"HI"));
states.add(new com.ubspw.cdd.common.LabelValueBean("IA",
"IA"));
states.add(new com.ubspw.cdd.common.LabelValueBean("ID",
"ID"));
states.add(new com.ubspw.cdd.common.LabelValueBean("IL",
"IL"));
states.add(new com.ubspw.cdd.common.LabelValueBean("IN",
"IN"));
states.add(new com.ubspw.cdd.common.LabelValueBean("KS",
"KS"));
states.add(new com.ubspw.cdd.common.LabelValueBean("KY",
"KY"));
states.add(new com.ubspw.cdd.common.LabelValueBean("LA",
"LA"));
states

RE: Need Help Fast

2002-09-26 Thread Smith, Johnathan M.

Can you please send me a sample of a better way

-Original Message-
From: Ville Peurala [mailto:
Sent: Thursday, September 26, 2002 8:26 AM
To: Struts Users Mailing List
Subject: RE: Need Help Fast


Hello,

One possible solution:

Put the ArrayList in application context and put a check in doStartTag()'s
beginning to determine whether the list of states can be found in
application context.

Instead of:

pageContext.setAttribute("selectStates", states);

Put it like this:

pageContext.setAttribute("selectStates", states,
PageContext.APPLICATION_SCOPE);

And in the beginning of doStartTag():

Object o = pageContext.getAttribute("selectStates",
PageContext.APPLICATION_SCOPE);
if (o == null) { ...do what your current code does...
}
else { ...do nothing... }

But why do this in a tag at all? If your list of states never changes, you
might as well initialize it in an init() method somewhere.

T: Ville Peurala


-Original Message-
From: Smith, Johnathan M. [mailto:[EMAIL PROTECTED]]
Sent: 26. syyskuuta 2002 15:13
To: 'Struts Users Mailing List'
Subject: Need Help Fast


This is not really a struts question but I am using struts a maybe someone
can help.  I system has allot of state dropdown's so I I made a tag for the
programmers to insert into the JSP pages. 

The Tag builds a ArrayList with the states in it and then saves the states
as a attribute in the pageContext. But I don't know if this is the best way
to do it.  Is it anyway to tell this code only to run one time and then stay
in member?

Below is my sample code: Please help me out

public int doStartTag() throws JspException {

java.util.ArrayList states = new java.util.ArrayList();
states.add(new com.ubspw.cdd.common.LabelValueBean("-Select
One-", ""));
states.add(new com.ubspw.cdd.common.LabelValueBean("AK",
"AK"));
states.add(new com.ubspw.cdd.common.LabelValueBean("AL",
"AL"));
states.add(new com.ubspw.cdd.common.LabelValueBean("AR",
"AR"));
states.add(new com.ubspw.cdd.common.LabelValueBean("AZ",
"AZ"));
states.add(new com.ubspw.cdd.common.LabelValueBean("CA",
"CA"));
states.add(new com.ubspw.cdd.common.LabelValueBean("CO",
"CO"));
states.add(new com.ubspw.cdd.common.LabelValueBean("CT",
"CT"));
states.add(new com.ubspw.cdd.common.LabelValueBean("DC",
"DC"));
states.add(new com.ubspw.cdd.common.LabelValueBean("DE",
"DE"));
states.add(new com.ubspw.cdd.common.LabelValueBean("FL",
"FL"));
states.add(new com.ubspw.cdd.common.LabelValueBean("GA",
"GA"));
states.add(new com.ubspw.cdd.common.LabelValueBean("HI",
"HI"));
states.add(new com.ubspw.cdd.common.LabelValueBean("IA",
"IA"));
states.add(new com.ubspw.cdd.common.LabelValueBean("ID",
"ID"));
states.add(new com.ubspw.cdd.common.LabelValueBean("IL",
"IL"));
states.add(new com.ubspw.cdd.common.LabelValueBean("IN",
"IN"));
states.add(new com.ubspw.cdd.common.LabelValueBean("KS",
"KS"));
states.add(new com.ubspw.cdd.common.LabelValueBean("KY",
"KY"));
states.add(new com.ubspw.cdd.common.LabelValueBean("LA",
"LA"));
states.add(new com.ubspw.cdd.common.LabelValueBean("MA",
"MA"));
states.add(new com.ubspw.cdd.common.LabelValueBean("MD",
"MD"));
states.add(new com.ubspw.cdd.common.LabelValueBean("ME",
"ME"));
states.add(new com.ubspw.cdd.common.LabelValueBean("MI",
"MI"));
states.add(new com.ubspw.cdd.common.LabelValueBean("MN",
"MN"));
states.add(new com.ubspw.cdd.common.LabelValueBean("MO",
"MO"));
states.add(new com.ubspw.cdd.common.LabelValueBean("MS",
"MS"));
states.add(new com.ubspw.cdd.common.LabelValueBean("MT",
"MT"));
states.add(new com.ubspw.cdd.common.LabelValueBean("NC",
"NC"));
states.add(new com.ubspw.cdd.common.LabelValueBean("ND",
"ND"));
states.add(new com.ubspw.cdd.common.LabelValueBean("NE",
"NE"));
states.add(new com.ubspw.cdd.common.LabelValueBean("NH",
&

RE: Need Help Fast

2002-09-26 Thread Ville Peurala

Hello,

One possible solution:

Put the ArrayList in application context and put a check in doStartTag()'s beginning 
to determine whether the list of states can be found in application context.

Instead of:

pageContext.setAttribute("selectStates", states);

Put it like this:

pageContext.setAttribute("selectStates", states, PageContext.APPLICATION_SCOPE);

And in the beginning of doStartTag():

Object o = pageContext.getAttribute("selectStates", PageContext.APPLICATION_SCOPE);
if (o == null) { ...do what your current code does...
}
else { ...do nothing... }

But why do this in a tag at all? If your list of states never changes, you might as 
well initialize it in an init() method somewhere.

T: Ville Peurala


-Original Message-
From: Smith, Johnathan M. [mailto:[EMAIL PROTECTED]]
Sent: 26. syyskuuta 2002 15:13
To: 'Struts Users Mailing List'
Subject: Need Help Fast


This is not really a struts question but I am using struts a maybe someone
can help.  I system has allot of state dropdown's so I I made a tag for the
programmers to insert into the JSP pages. 

The Tag builds a ArrayList with the states in it and then saves the states
as a attribute in the pageContext. But I don't know if this is the best way
to do it.  Is it anyway to tell this code only to run one time and then stay
in member?

Below is my sample code: Please help me out

public int doStartTag() throws JspException {

java.util.ArrayList states = new java.util.ArrayList();
states.add(new com.ubspw.cdd.common.LabelValueBean("-Select
One-", ""));
states.add(new com.ubspw.cdd.common.LabelValueBean("AK",
"AK"));
states.add(new com.ubspw.cdd.common.LabelValueBean("AL",
"AL"));
states.add(new com.ubspw.cdd.common.LabelValueBean("AR",
"AR"));
states.add(new com.ubspw.cdd.common.LabelValueBean("AZ",
"AZ"));
states.add(new com.ubspw.cdd.common.LabelValueBean("CA",
"CA"));
states.add(new com.ubspw.cdd.common.LabelValueBean("CO",
"CO"));
states.add(new com.ubspw.cdd.common.LabelValueBean("CT",
"CT"));
states.add(new com.ubspw.cdd.common.LabelValueBean("DC",
"DC"));
states.add(new com.ubspw.cdd.common.LabelValueBean("DE",
"DE"));
states.add(new com.ubspw.cdd.common.LabelValueBean("FL",
"FL"));
states.add(new com.ubspw.cdd.common.LabelValueBean("GA",
"GA"));
states.add(new com.ubspw.cdd.common.LabelValueBean("HI",
"HI"));
states.add(new com.ubspw.cdd.common.LabelValueBean("IA",
"IA"));
states.add(new com.ubspw.cdd.common.LabelValueBean("ID",
"ID"));
states.add(new com.ubspw.cdd.common.LabelValueBean("IL",
"IL"));
states.add(new com.ubspw.cdd.common.LabelValueBean("IN",
"IN"));
states.add(new com.ubspw.cdd.common.LabelValueBean("KS",
"KS"));
states.add(new com.ubspw.cdd.common.LabelValueBean("KY",
"KY"));
states.add(new com.ubspw.cdd.common.LabelValueBean("LA",
"LA"));
states.add(new com.ubspw.cdd.common.LabelValueBean("MA",
"MA"));
states.add(new com.ubspw.cdd.common.LabelValueBean("MD",
"MD"));
states.add(new com.ubspw.cdd.common.LabelValueBean("ME",
"ME"));
states.add(new com.ubspw.cdd.common.LabelValueBean("MI",
"MI"));
states.add(new com.ubspw.cdd.common.LabelValueBean("MN",
"MN"));
states.add(new com.ubspw.cdd.common.LabelValueBean("MO",
"MO"));
states.add(new com.ubspw.cdd.common.LabelValueBean("MS",
"MS"));
states.add(new com.ubspw.cdd.common.LabelValueBean("MT",
"MT"));
states.add(new com.ubspw.cdd.common.LabelValueBean("NC",
"NC"));
states.add(new com.ubspw.cdd.common.LabelValueBean("ND",
"ND"));
states.add(new com.ubspw.cdd.common.LabelValueBean("NE",
"NE"));
states.add(new com.ubspw.cdd.common.LabelValueBean("NH",
"NH"));
states.add(new com.ubspw.cdd.common.LabelValueBean("NJ",
"NJ"));
states.add(new com.ubspw.cdd.common.LabelValueBean("NM",
"NM"));
states.add(new com.ubspw.cdd.common.LabelValueBean("NV",
"NV"));
states.add(new com.ubspw.cdd.common.LabelValueBean("NY",
"NY"));
states.add(new com.ubspw.cdd.common.LabelValueBean("OH",
"OH"));
states.add(new com.ubspw.cdd.common.LabelValueBean("OK",
"OK"));
states.add(new com.ubspw.cdd.common.LabelValueBean("OR",
"OR"));
states.add(new com.ubspw.cdd.common.LabelValueBean("PA",
"PA"));
states.add(new com.ubspw.cdd.common.LabelValueBean("PR",
"PR"));
states.add(new com.ubspw.cdd.common.LabelValueBean("RI",
"RI"));
states.add(new com.ubspw.cdd.common.LabelValueBean("SC",
"SC"));
 

RE: Need Help Fast

2002-09-26 Thread Robert Taylor

Retrieve you states when the application starts up. Either init Servlet or
ServletContextListener.
Place collection of states in ServletContext where they will be available to
all users for the life time of the application.

Use  to render the states.



robert

> -Original Message-
> From: Smith, Johnathan M. [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 26, 2002 8:13 AM
> To: 'Struts Users Mailing List'
> Subject: Need Help Fast
>
>
> This is not really a struts question but I am using struts a maybe someone
> can help.  I system has allot of state dropdown's so I I made a
> tag for the
> programmers to insert into the JSP pages.
>
> The Tag builds a ArrayList with the states in it and then saves the states
> as a attribute in the pageContext. But I don't know if this is
> the best way
> to do it.  Is it anyway to tell this code only to run one time
> and then stay
> in member?
>
> Below is my sample code: Please help me out
>
> public int doStartTag() throws JspException {
>
>   java.util.ArrayList states = new java.util.ArrayList();
>   states.add(new com.ubspw.cdd.common.LabelValueBean("-Select
> One-", ""));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("AK",
> "AK"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("AL",
> "AL"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("AR",
> "AR"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("AZ",
> "AZ"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("CA",
> "CA"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("CO",
> "CO"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("CT",
> "CT"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("DC",
> "DC"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("DE",
> "DE"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("FL",
> "FL"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("GA",
> "GA"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("HI",
> "HI"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("IA",
> "IA"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("ID",
> "ID"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("IL",
> "IL"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("IN",
> "IN"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("KS",
> "KS"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("KY",
> "KY"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("LA",
> "LA"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("MA",
> "MA"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("MD",
> "MD"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("ME",
> "ME"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("MI",
> "MI"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("MN",
> "MN"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("MO",
> "MO"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("MS",
> "MS"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("MT",
> "MT"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("NC",
> "NC"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("ND",
> "ND"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("NE",
> "NE"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("NH",
> "NH"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("NJ",
> "NJ"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("NM",
> "NM"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("NV",
> "NV"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("NY",
> "NY"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("OH",
> "OH"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("OK",
> "OK"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("OR",
> "OR"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("PA",
> "PA"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("PR",
> "PR"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("RI",
> "RI"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("SC",
> "SC"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("SD",
> "SD"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("TN",
> "TN"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("TX",
> "TX"));
>   states.add(new com.ubspw.cdd.common.LabelValueBean("UT",
> "UT"));
>