Re: Best Practice Question/Conceptual Problem

2002-06-26 Thread Ted Husted

There's an option for using a Map if you need more than one parameter. 

Struts Newsgroup (@Basebeans.com) wrote:
 
 Subject: Re: Best Practice Question/Conceptual Problem
 From: Kenny Smith [EMAIL PROTECTED]
  ===
 Hi Mark et al,
 
 Thank you all for your help, I've gotten it to work, and I understand the
 concept now. My next hurdle is using the bean data in html:link tags. I've
 found that I can use the paramId, paramName and paramProperty tags to add a
 parameter to the html:link, but what if I want to add 2 params? It seems
 kind of silly to hardcode the ability to add one parameter. Am I missing
 something?
 
 Kenny Smith
 
 --
 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]




RE: Best Practice Question/Conceptual Problem

2002-06-25 Thread Kamholz, Keith (corp-staff) USX

can you really use bean:define before the logic:iterate tag?  I did
something similar (i forget if i used bean:define or jsp:useBean) and I
got errors complaining about the id variable already existing or that it had
already been declared.  i may have been doing something wrong, but it didn't
work for me.

Keith Kamholz
Moog 
East Aurora, NY
(716) 687-7282
[EMAIL PROTECTED]


-Original Message-
From: Galbreath, Mark [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 24, 2002 4:40 PM
To: 'Struts Users Mailing List'
Subject: RE: Best Practice Question/Conceptual Problem


It gets it from a JavaBean, List or Map either already in some reachable
scope or defined in your JSP.  For example, if I've defined a list of states
in an action class like:


List statesList = new ArrayList( State.getStates());

where State is a command object or stateless session bean querying the
database to retrieve a list of states, and I stick them into application
scope (so everyone can use it):

ServletContext servletContext = this.servlet.getServletContext();
servletContext.setAttribute( listStates, listStates);

I can iterate through this list on a JSP and display the names like:

table
logic:iterate name=listStates  // the List
   property=state   // a state object
   id=states// arbitrary page-scope name
   scope=application
   type=com.whatever.State
trtd
bean:write name=states property=name /
/td/tr
/logic:iterate
/table

or perhaps I need a data object specific to the user on the JSP:

bean:define name=customer
 property=data
 type=com.whatever.Customer
 id=orders
 scope=session /

where customer is an Order object specific to this customer's ID
(retrieved from the database when the user passes his ID through a form), so
I can display the pending orders this customer has placed:

table
logic:iterate name=orders
   property=customerOrders
   id=order
   type=com.whatever.CustomerOrder
trtd
bean:write name=order property=pending /
/td/tr
/logic:iterate
/table


There are tons of examples in the archive.

Mark

-Original Message-
From: Struts Newsgroup [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 24, 2002 4:10 PM

Subject: Re: Best Practice Question/Conceptual Problem
From: Kenny Smith [EMAIL PROTECTED]
 ===
Hi Keith,

But how does the logic:iterate tag know where to get the information from?
That's the part that is really baffling me. I don't understand how it's
getting the information, so I'm not sure how to apply it to other
applications, etc. Could you (or anyone) please explain how it knows?

Kenny




--
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]

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




Best Practice Question/Conceptual Problem

2002-06-24 Thread @Basebeans.com

Subject: Best Practice Question/Conceptual Problem
From: Kenny Smith [EMAIL PROTECTED]
 ===
Hello,

I'm trying to write my first struts application, and I'm looking for
guidance on how to accomplish a certain task. I've read through the Struts
Userguide and I've been going through the struts-example application, but
I'm not exactly sure what concept I'm missing that is keeping me from
wrapping my head around the problem.

I have a list of markets in a database table. I have a Market bean that
can be instantiated to represent a row in the table, and it has static
methods for finding markets by id, creating markets, etc. I would like my
user to be able to click a List Active Markets link and have it take them
to a page where it lists the markets.

Seems simple enough, but I can't figure out how to make the data available
to my JSP page. I assume I should use a logic:iterate tag to display data
for each of the markets, but I just don't understand how I make the data
available to the JSP or logic:iterate tag.

I've been reading and reading, and I can't figure it out, there seems to be
some piece missing. Can anyone help me? This seems like a fairly
basic/common action, so is there anyone out there that has suggestions for
the best practice solution?

Thanks,
Kenny Smith
JournalScape.com



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




RE: Best Practice Question/Conceptual Problem

2002-06-24 Thread wbchmura

Hi

When your users request the list, the request goes to an action...

The action calls the appropriate things to get the data...

It then stuffs the information into the session and forwards the request 
to a JSP page

The JSP page pulls the data out, builds the page and sends it back to 
the user...

Does that help?


-Original Message-
From: struts [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 24, 2002 12:25 PM
To: struts-user
Subject: Best Practice Question/Conceptual Problem


Subject: Best Practice Question/Conceptual Problem
From: Kenny Smith [EMAIL PROTECTED]
 ===
Hello,

I'm trying to write my first struts application, and I'm looking for
guidance on how to accomplish a certain task. I've read through the 
Struts
Userguide and I've been going through the struts-example application, 
but
I'm not exactly sure what concept I'm missing that is keeping me from
wrapping my head around the problem.

I have a list of markets in a database table. I have a Market bean 
that
can be instantiated to represent a row in the table, and it has static
methods for finding markets by id, creating markets, etc. I would like 
my
user to be able to click a List Active Markets link and have it take 
them
to a page where it lists the markets.

Seems simple enough, but I can't figure out how to make the data 
available
to my JSP page. I assume I should use a logic:iterate tag to display 
data
for each of the markets, but I just don't understand how I make the data
available to the JSP or logic:iterate tag.

I've been reading and reading, and I can't figure it out, there seems to 
be
some piece missing. Can anyone help me? This seems like a fairly
basic/common action, so is there anyone out there that has suggestions 
for
the best practice solution?

Thanks,
Kenny Smith
JournalScape.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]




Re: Best Practice Question/Conceptual Problem

2002-06-24 Thread @Basebeans.com

Subject: Re: Best Practice Question/Conceptual Problem
From: Kenny Smith [EMAIL PROTECTED]
 ===
 It then stuffs the information into the session and forwards the request
 to a JSP page

 The JSP page pulls the data out, builds the page and sends it back to
 the user...

 Does that help?

Somewhat, yes. I understand how to get the information, but putting it in
the session and retreiving it is where I sort of fall down. I understand the
syntax of putting something in the session (although I haven't been able to
find where the Constants class is, that is used in every example).. but
something like:

Market[] markets = Market.findByActive( true ) ;
HttpSession session = request.getSession() ;
session.put( markets , markets ) ;

Is that correct?

but how do I get it out of the session to use with the logic:iterate tag?

Thanks for the reply,
Kenny



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




RE: Best Practice Question/Conceptual Problem

2002-06-24 Thread Kamholz, Keith (corp-staff) USX

Use something like this:
logic:iterate id=temp name=markets type=Market
Do this on each iteration
/logic:iterate

The tag should take care of everything for you.  I forget if you have to
specify scope=session in the logic:iterate, but if you have problems try
adding it.

~ Keith


-Original Message-
From: Struts Newsgroup [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 24, 2002 2:25 PM
To: [EMAIL PROTECTED]
Subject: Re: Best Practice Question/Conceptual Problem


Subject: Re: Best Practice Question/Conceptual Problem
From: Kenny Smith [EMAIL PROTECTED]
 ===
 It then stuffs the information into the session and forwards the request
 to a JSP page

 The JSP page pulls the data out, builds the page and sends it back to
 the user...

 Does that help?

Somewhat, yes. I understand how to get the information, but putting it in
the session and retreiving it is where I sort of fall down. I understand the
syntax of putting something in the session (although I haven't been able to
find where the Constants class is, that is used in every example).. but
something like:

Market[] markets = Market.findByActive( true ) ;
HttpSession session = request.getSession() ;
session.put( markets , markets ) ;

Is that correct?

but how do I get it out of the session to use with the logic:iterate tag?

Thanks for the reply,
Kenny



--
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]




Re: Best Practice Question/Conceptual Problem

2002-06-24 Thread @Basebeans.com

Subject: Re: Best Practice Question/Conceptual Problem
From: Kenny Smith [EMAIL PROTECTED]
 ===
Hi Keith,

But how does the logic:iterate tag know where to get the information from?
That's the part that is really baffling me. I don't understand how it's
getting the information, so I'm not sure how to apply it to other
applications, etc. Could you (or anyone) please explain how it knows?

Kenny




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




RE: Best Practice Question/Conceptual Problem

2002-06-24 Thread James Mitchell

Your best bet is to take a look at some source code for the taglibs, it can
clear up a few things for you.

HTH!

James Mitchell
Software Engineer\Struts Evangelist
Struts-Atlanta, the Open Minded Developer Network
http://struts-atlanta.open-tools.org

 -Original Message-
 From: Struts Newsgroup [mailto:@[EMAIL PROTECTED]]
 Sent: Monday, June 24, 2002 4:10 PM
 To: [EMAIL PROTECTED]
 Subject: Re: Best Practice Question/Conceptual Problem


 Subject: Re: Best Practice Question/Conceptual Problem
 From: Kenny Smith [EMAIL PROTECTED]
  ===
 Hi Keith,

 But how does the logic:iterate tag know where to get the information from?
 That's the part that is really baffling me. I don't understand how it's
 getting the information, so I'm not sure how to apply it to other
 applications, etc. Could you (or anyone) please explain how it knows?

 Kenny




 --
 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]




Re: Best Practice Question/Conceptual Problem

2002-06-24 Thread Ted Husted

The name parameter you pass to the iterate tag matches the name of the
attribute in (page,request,session,application) scope. 

In other words, the context and the tags use the same protocol for the
property names. 

The other parameter to iterate, id, tells the tag what name to use when
it exposes each entry in the collection. 

The tag looks in the page context first, then request, session, and
application. (Unless you specify a scope.)

Struts Newsgroup (@Basebeans.com) wrote:
 
 Subject: Re: Best Practice Question/Conceptual Problem
 From: Kenny Smith [EMAIL PROTECTED]
  ===
 Hi Keith,
 
 But how does the logic:iterate tag know where to get the information from?
 That's the part that is really baffling me. I don't understand how it's
 getting the information, so I'm not sure how to apply it to other
 applications, etc. Could you (or anyone) please explain how it knows?
 
 Kenny

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




RE: Best Practice Question/Conceptual Problem

2002-06-24 Thread Galbreath, Mark

It gets it from a JavaBean, List or Map either already in some reachable
scope or defined in your JSP.  For example, if I've defined a list of states
in an action class like:


List statesList = new ArrayList( State.getStates());

where State is a command object or stateless session bean querying the
database to retrieve a list of states, and I stick them into application
scope (so everyone can use it):

ServletContext servletContext = this.servlet.getServletContext();
servletContext.setAttribute( listStates, listStates);

I can iterate through this list on a JSP and display the names like:

table
logic:iterate name=listStates  // the List
   property=state   // a state object
   id=states// arbitrary page-scope name
   scope=application
   type=com.whatever.State
trtd
bean:write name=states property=name /
/td/tr
/logic:iterate
/table

or perhaps I need a data object specific to the user on the JSP:

bean:define name=customer
 property=data
 type=com.whatever.Customer
 id=orders
 scope=session /

where customer is an Order object specific to this customer's ID
(retrieved from the database when the user passes his ID through a form), so
I can display the pending orders this customer has placed:

table
logic:iterate name=orders
   property=customerOrders
   id=order
   type=com.whatever.CustomerOrder
trtd
bean:write name=order property=pending /
/td/tr
/logic:iterate
/table


There are tons of examples in the archive.

Mark

-Original Message-
From: Struts Newsgroup [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 24, 2002 4:10 PM

Subject: Re: Best Practice Question/Conceptual Problem
From: Kenny Smith [EMAIL PROTECTED]
 ===
Hi Keith,

But how does the logic:iterate tag know where to get the information from?
That's the part that is really baffling me. I don't understand how it's
getting the information, so I'm not sure how to apply it to other
applications, etc. Could you (or anyone) please explain how it knows?

Kenny




--
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]