RE: Re[2]: [OT] Re: 4th Of July Struts Challenge...

2003-07-16 Thread Craig R. McClanahan


On Wed, 16 Jul 2003, Larry Zappeterrini wrote:

> Date: Wed, 16 Jul 2003 11:08:46 -0400
> From: Larry Zappeterrini <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: 'Struts Users Mailing List' <[EMAIL PROTECTED]>
> Subject: RE: Re[2]: [OT] Re: 4th Of July Struts Challenge...
>
> That analysis of constructors is correct. Regarding the question about
> JavaBeans and constructors, the document "How to be a Good Bean" from Sun's
> website (http://java.sun.com/products/javabeans/docs/goodbean.pdf) indicates
> that it is good practice to provide a zero-argument constructor for a
> JavaBean. This is so that an instance of the bean can be created using
> Beans.instantiate().
>

Indeed, Struts itself relies on this to instantiate things like Action and
ActionForm beans dynamically.

Craig

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



RE: [OT] Re: 4th Of July Struts Challenge...

2003-07-16 Thread Micael
The no-argument constructor is available from default ONLY if you do not 
have another constructor, Mark.  If you have another constructor with an 
argument, then the no-argument constructor is not there by default and must 
be coded.  There is no need to test this.  It is that way.

I would always make a class serializable in this situation.

At 10:29 AM 7/16/03 -0400, you wrote:
I have not found this in the spec, but I believe the no-argument constructor
is available at anytime for a concrete class.  This would be a good one to
test
-Original Message-
From: Michael Duffy [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 16, 2003 10:27 AM
To: Struts Users Mailing List
Subject: RE: [OT] Re: 4th Of July Struts Challenge...


It's my understanding that you ONLY get the default if
there are no other constructors written.  The minute
you write ANY constructor, you're on your own.  If you
still want a default ctor, you've gotta supply it.
I'll be happy to learn something if this is incorrect.
- MOD
--- Mark Galbreath <[EMAIL PROTECTED]> wrote:
> The no-argument constructor is the default and does
> not have to be declared.
> You have a 2-arg constructor.  As for JSTL (or any
> EL) acting like straight
> scripting, I've never had an argument with using
> scripting where
> appropriate.  Pragmatism should be the rule of the
> day.  Finally, I don't
> know why declaring DynaActionForm beans as Maps
> didn't work for me, but
> neither is it a big issue. I realize the constraints
> of declaring a variable
> as a concrete/abstract class vs. as an interface.
>
> Besides, I like what you've created. :-)
>
> -Original Message-
> From: Kris Schneider [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, July 16, 2003 8:55 AM
> To: Struts Users Mailing List
> Subject: RE: [OT] Re: 4th Of July Struts
> Challenge...
>
>
> Quoting Mark Galbreath <[EMAIL PROTECTED]>:
>
> > A few comments:
> >
> > 1.  I got runtime errors when I declared a
> DynaActionForm bean of type
> > Map; I had to declare it of type HashMap.
>
> Not sure what you're doing, but the example works as
> coded. If it matters,
> post some details and we'll see if something needs
> fixing.
>
> > 2.  You may be using JSTL, but it still looks like
> scripting to
> > me.
>
> Fair enough. What's your recommended alternative to
> JSTL when using JSP for
> your view layer?
>
> > 3.  Strictly speaking, JavaBeans do not contain a
> constructor and
> > implement Serializable.
>
> Strictly speaking, a JavaBean *does* contain a
> construtctor (or even more
> than one), just like any other Java class. It's just
> that a "real" bean
> needs to have a no-arg constructor. The actual code
> that I uploaded to Rick
> includes a no-arg construtctor for EmployeeBean but
> omitted implementing
> Serializable or Externalizable. The bean also fails
> to act as an event
> source and it doesn't check for things like null
> values passed to either its
> construtctor or its set methods.
>
> > Mark
> >
> > -Original Message-
> > From: Rick Reumann [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, July 15, 2003 11:44 PM
> > To: Struts Users Mailing List
> > Subject: [OT] Re: 4th Of July Struts Challenge...
> >
> >
> > Kris... this was just awesome! Thanks. You da
> 'man:)
> >
> > On Tue, Jul 15,'03 (11:25 AM GMT-0400), Kris
> wrote:
> >
> > > As it turns out, some of my ideas about a
> "standard" property of
> > > type
> > > Map versus a "mapped property" were a bit off.
> So, if you're still
> > > interested, here's something I hacked together.
> You'll notice I used a
> > > session scoped form so that Struts doesn't choke
> when it tries to
> > > populate the form.
> > >
> > > struts-config.xml:
> > > --
> > >
> > > 
> > >  > >
> type="org.apache.struts.action.DynaActionForm">
> > >  type="java.util.Map"/>
> > > 
> > > 
> > >
> > > 
> > >  > >
> type="com.dotech.EditEmployeesAction"
> > > name="employeesForm"
> > > scope="session"
> > > validate="false">
> > >  path="/editEmployees.jsp"/>
> > > 
> > >  > >
> type="org.apache.strut

RE: Re[2]: [OT] Re: 4th Of July Struts Challenge...

2003-07-16 Thread Larry Zappeterrini
That analysis of constructors is correct. Regarding the question about
JavaBeans and constructors, the document "How to be a Good Bean" from Sun's
website (http://java.sun.com/products/javabeans/docs/goodbean.pdf) indicates
that it is good practice to provide a zero-argument constructor for a
JavaBean. This is so that an instance of the bean can be created using
Beans.instantiate().

-Original Message-
From: Dirk Markert [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 16, 2003 11:01 AM
To: Struts Users Mailing List
Subject: Re[2]: [OT] Re: 4th Of July Struts Challenge...


Hello Mark,

  

***

MG> I have not found this
but I have:

If the source code for a class contains no declared constructors, the Java
compiler
automatically supplies a constructor with no parameters. Adding one or more
constructor declarations to the source code of such a class will prevent
this default
constructor from being supplied automatically, effectively deleting a
constructor,
unless one of the new constructors also has no parameters, thus replacing
the
default constructor.

JLS, page 267

MG>  in the spec, but I believe the no-argument constructor
MG> is available at anytime for a concrete class.  This would be a good one
to
MG> test


MG> -Original Message-
MG> From: Michael Duffy [mailto:[EMAIL PROTECTED] 
MG> Sent: Wednesday, July 16, 2003 10:27 AM
MG> To: Struts Users Mailing List
MG> Subject: RE: [OT] Re: 4th Of July Struts Challenge...



MG> It's my understanding that you ONLY get the default if
MG> there are no other constructors written.  The minute
MG> you write ANY constructor, you're on your own.  If you
MG> still want a default ctor, you've gotta supply it. 

MG> I'll be happy to learn something if this is incorrect.
MG> - MOD


MG> --- Mark Galbreath <[EMAIL PROTECTED]> wrote:
>> The no-argument constructor is the default and does
>> not have to be declared.
>> You have a 2-arg constructor.  As for JSTL (or any
>> EL) acting like straight
>> scripting, I've never had an argument with using
>> scripting where
>> appropriate.  Pragmatism should be the rule of the
>> day.  Finally, I don't
>> know why declaring DynaActionForm beans as Maps
>> didn't work for me, but
>> neither is it a big issue. I realize the constraints
>> of declaring a variable
>> as a concrete/abstract class vs. as an interface.
>> 
>> Besides, I like what you've created. :-)
>> 
>> -Original Message-
>> From: Kris Schneider [mailto:[EMAIL PROTECTED]
>> Sent: Wednesday, July 16, 2003 8:55 AM
>> To: Struts Users Mailing List
>> Subject: RE: [OT] Re: 4th Of July Struts
>> Challenge...
>> 
>> 
>> Quoting Mark Galbreath <[EMAIL PROTECTED]>:
>> 
>> > A few comments:
>> > 
>> > 1.  I got runtime errors when I declared a
>> DynaActionForm bean of type
>> > Map; I had to declare it of type HashMap.
>> 
>> Not sure what you're doing, but the example works as
>> coded. If it matters,
>> post some details and we'll see if something needs
>> fixing.
>> 
>> > 2.  You may be using JSTL, but it still looks like
>> scripting to
>> > me.
>> 
>> Fair enough. What's your recommended alternative to
>> JSTL when using JSP for
>> your view layer?
>> 
>> > 3.  Strictly speaking, JavaBeans do not contain a
>> constructor and
>> > implement Serializable.
>> 
>> Strictly speaking, a JavaBean *does* contain a
>> construtctor (or even more
>> than one), just like any other Java class. It's just
>> that a "real" bean
>> needs to have a no-arg constructor. The actual code
>> that I uploaded to Rick
>> includes a no-arg construtctor for EmployeeBean but
>> omitted implementing
>> Serializable or Externalizable. The bean also fails
>> to act as an event
>> source and it doesn't check for things like null
>> values passed to either its
>> construtctor or its set methods.
>> 
>> > Mark
>> > 
>> > -Original Message-
>> > From: Rick Reumann [mailto:[EMAIL PROTECTED]
>> > Sent: Tuesday, July 15, 2003 11:44 PM
>> > To: Struts Users Mailing List
>> > Subject: [OT] Re: 4th Of July Struts Challenge...
>> > 
>> > 
>> > Kris... this was just awesome! Thanks. You da
>> 'man:)
>> > 
>> > On Tue, Jul 15,'03 (11:25 AM GMT-0400), Kris
>> wrote:
>> > 
>> > > As it turns out, som

Re[2]: [OT] Re: 4th Of July Struts Challenge...

2003-07-16 Thread Dirk Markert
Hello Mark,

  

***

MG> I have not found this
but I have:

If the source code for a class contains no declared constructors, the Java compiler
automatically supplies a constructor with no parameters. Adding one or more
constructor declarations to the source code of such a class will prevent this default
constructor from being supplied automatically, effectively deleting a constructor,
unless one of the new constructors also has no parameters, thus replacing the
default constructor.

JLS, page 267

MG>  in the spec, but I believe the no-argument constructor
MG> is available at anytime for a concrete class.  This would be a good one to
MG> test


MG> -Original Message-
MG> From: Michael Duffy [mailto:[EMAIL PROTECTED] 
MG> Sent: Wednesday, July 16, 2003 10:27 AM
MG> To: Struts Users Mailing List
MG> Subject: RE: [OT] Re: 4th Of July Struts Challenge...



MG> It's my understanding that you ONLY get the default if
MG> there are no other constructors written.  The minute
MG> you write ANY constructor, you're on your own.  If you
MG> still want a default ctor, you've gotta supply it. 

MG> I'll be happy to learn something if this is incorrect.
MG> - MOD


MG> --- Mark Galbreath <[EMAIL PROTECTED]> wrote:
>> The no-argument constructor is the default and does
>> not have to be declared.
>> You have a 2-arg constructor.  As for JSTL (or any
>> EL) acting like straight
>> scripting, I've never had an argument with using
>> scripting where
>> appropriate.  Pragmatism should be the rule of the
>> day.  Finally, I don't
>> know why declaring DynaActionForm beans as Maps
>> didn't work for me, but
>> neither is it a big issue. I realize the constraints
>> of declaring a variable
>> as a concrete/abstract class vs. as an interface.
>> 
>> Besides, I like what you've created. :-)
>> 
>> -----Original Message-
>> From: Kris Schneider [mailto:[EMAIL PROTECTED]
>> Sent: Wednesday, July 16, 2003 8:55 AM
>> To: Struts Users Mailing List
>> Subject: RE: [OT] Re: 4th Of July Struts
>> Challenge...
>> 
>> 
>> Quoting Mark Galbreath <[EMAIL PROTECTED]>:
>> 
>> > A few comments:
>> > 
>> > 1.  I got runtime errors when I declared a
>> DynaActionForm bean of type
>> > Map; I had to declare it of type HashMap.
>> 
>> Not sure what you're doing, but the example works as
>> coded. If it matters,
>> post some details and we'll see if something needs
>> fixing.
>> 
>> > 2.  You may be using JSTL, but it still looks like
>> scripting to
>> > me.
>> 
>> Fair enough. What's your recommended alternative to
>> JSTL when using JSP for
>> your view layer?
>> 
>> > 3.  Strictly speaking, JavaBeans do not contain a
>> constructor and
>> > implement Serializable.
>> 
>> Strictly speaking, a JavaBean *does* contain a
>> construtctor (or even more
>> than one), just like any other Java class. It's just
>> that a "real" bean
>> needs to have a no-arg constructor. The actual code
>> that I uploaded to Rick
>> includes a no-arg construtctor for EmployeeBean but
>> omitted implementing
>> Serializable or Externalizable. The bean also fails
>> to act as an event
>> source and it doesn't check for things like null
>> values passed to either its
>> construtctor or its set methods.
>> 
>> > Mark
>> > 
>> > -Original Message-
>> > From: Rick Reumann [mailto:[EMAIL PROTECTED]
>> > Sent: Tuesday, July 15, 2003 11:44 PM
>> > To: Struts Users Mailing List
>> > Subject: [OT] Re: 4th Of July Struts Challenge...
>> > 
>> > 
>> > Kris... this was just awesome! Thanks. You da
>> 'man:)
>> > 
>> > On Tue, Jul 15,'03 (11:25 AM GMT-0400), Kris
>> wrote:
>> > 
>> > > As it turns out, some of my ideas about a
>> "standard" property of
>> > > type
>> > > Map versus a "mapped property" were a bit off.
>> So, if you're still
>> > > interested, here's something I hacked together.
>> You'll notice I used a
>> > > session scoped form so that Struts doesn't choke
>> when it tries to
>> > > populate the form.
>> > > 
>> > > struts-config.xml:
>> > > --
>> > > 
>> > > 
>> > > > > 

RE: [OT] Re: 4th Of July Struts Challenge...

2003-07-16 Thread Andrew Hill
I do not believe this to be the case. Indeed Im 99% certain it is not the
case.
I suppose I should bang together a class to prove this, but it will be more
fun to argue about it for a while yet ;-)

-Original Message-
From: Mark Galbreath [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 16 July 2003 22:30
To: 'Struts Users Mailing List'
Subject: RE: [OT] Re: 4th Of July Struts Challenge...


I have not found this in the spec, but I believe the no-argument constructor
is available at anytime for a concrete class.  This would be a good one to
test


-Original Message-
From: Michael Duffy [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 16, 2003 10:27 AM
To: Struts Users Mailing List
Subject: RE: [OT] Re: 4th Of July Struts Challenge...



It's my understanding that you ONLY get the default if
there are no other constructors written.  The minute
you write ANY constructor, you're on your own.  If you
still want a default ctor, you've gotta supply it.

I'll be happy to learn something if this is incorrect.
- MOD


--- Mark Galbreath <[EMAIL PROTECTED]> wrote:
> The no-argument constructor is the default and does
> not have to be declared.
> You have a 2-arg constructor.  As for JSTL (or any
> EL) acting like straight
> scripting, I've never had an argument with using
> scripting where
> appropriate.  Pragmatism should be the rule of the
> day.  Finally, I don't
> know why declaring DynaActionForm beans as Maps
> didn't work for me, but
> neither is it a big issue. I realize the constraints
> of declaring a variable
> as a concrete/abstract class vs. as an interface.
>
> Besides, I like what you've created. :-)
>
> -Original Message-
> From: Kris Schneider [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, July 16, 2003 8:55 AM
> To: Struts Users Mailing List
> Subject: RE: [OT] Re: 4th Of July Struts
> Challenge...
>
>
> Quoting Mark Galbreath <[EMAIL PROTECTED]>:
>
> > A few comments:
> >
> > 1.  I got runtime errors when I declared a
> DynaActionForm bean of type
> > Map; I had to declare it of type HashMap.
>
> Not sure what you're doing, but the example works as
> coded. If it matters,
> post some details and we'll see if something needs
> fixing.
>
> > 2.  You may be using JSTL, but it still looks like
> scripting to
> > me.
>
> Fair enough. What's your recommended alternative to
> JSTL when using JSP for
> your view layer?
>
> > 3.  Strictly speaking, JavaBeans do not contain a
> constructor and
> > implement Serializable.
>
> Strictly speaking, a JavaBean *does* contain a
> construtctor (or even more
> than one), just like any other Java class. It's just
> that a "real" bean
> needs to have a no-arg constructor. The actual code
> that I uploaded to Rick
> includes a no-arg construtctor for EmployeeBean but
> omitted implementing
> Serializable or Externalizable. The bean also fails
> to act as an event
> source and it doesn't check for things like null
> values passed to either its
> construtctor or its set methods.
>
> > Mark
> >
> > -Original Message-
> > From: Rick Reumann [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, July 15, 2003 11:44 PM
> > To: Struts Users Mailing List
> > Subject: [OT] Re: 4th Of July Struts Challenge...
> >
> >
> > Kris... this was just awesome! Thanks. You da
> 'man:)
> >
> > On Tue, Jul 15,'03 (11:25 AM GMT-0400), Kris
> wrote:
> >
> > > As it turns out, some of my ideas about a
> "standard" property of
> > > type
> > > Map versus a "mapped property" were a bit off.
> So, if you're still
> > > interested, here's something I hacked together.
> You'll notice I used a
> > > session scoped form so that Struts doesn't choke
> when it tries to
> > > populate the form.
> > >
> > > struts-config.xml:
> > > --
> > >
> > > 
> > >  > >
> type="org.apache.struts.action.DynaActionForm">
> > >  type="java.util.Map"/>
> > > 
> > > 
> > >
> > > 
> > >  > >
> type="com.dotech.EditEmployeesAction"
> > > name="employeesForm"
> > > scope="session"
> > > validate="false">
> > >  path="/editEmployees.jsp"/>
> > > 
> > >  > >
> type="org.ap

RE: [OT] Re: 4th Of July Struts Challenge...

2003-07-16 Thread Kris Schneider
Quoting Michael Duffy <[EMAIL PROTECTED]>:

> 
> It's my understanding that you ONLY get the default if
> there are no other constructors written.  The minute
> you write ANY constructor, you're on your own.  If you
> still want a default ctor, you've gotta supply it. 
> 
> I'll be happy to learn something if this is incorrect.
> - MOD

That's correct.

8< snip >8

-- 
Kris Schneider 
D.O.Tech   

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



RE: [OT] Re: 4th Of July Struts Challenge...

2003-07-16 Thread Mark Galbreath
I have not found this in the spec, but I believe the no-argument constructor
is available at anytime for a concrete class.  This would be a good one to
test


-Original Message-
From: Michael Duffy [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 16, 2003 10:27 AM
To: Struts Users Mailing List
Subject: RE: [OT] Re: 4th Of July Struts Challenge...



It's my understanding that you ONLY get the default if
there are no other constructors written.  The minute
you write ANY constructor, you're on your own.  If you
still want a default ctor, you've gotta supply it. 

I'll be happy to learn something if this is incorrect.
- MOD


--- Mark Galbreath <[EMAIL PROTECTED]> wrote:
> The no-argument constructor is the default and does
> not have to be declared.
> You have a 2-arg constructor.  As for JSTL (or any
> EL) acting like straight
> scripting, I've never had an argument with using
> scripting where
> appropriate.  Pragmatism should be the rule of the
> day.  Finally, I don't
> know why declaring DynaActionForm beans as Maps
> didn't work for me, but
> neither is it a big issue. I realize the constraints
> of declaring a variable
> as a concrete/abstract class vs. as an interface.
> 
> Besides, I like what you've created. :-)
> 
> -Original Message-
> From: Kris Schneider [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, July 16, 2003 8:55 AM
> To: Struts Users Mailing List
> Subject: RE: [OT] Re: 4th Of July Struts
> Challenge...
> 
> 
> Quoting Mark Galbreath <[EMAIL PROTECTED]>:
> 
> > A few comments:
> > 
> > 1.  I got runtime errors when I declared a
> DynaActionForm bean of type
> > Map; I had to declare it of type HashMap.
> 
> Not sure what you're doing, but the example works as
> coded. If it matters,
> post some details and we'll see if something needs
> fixing.
> 
> > 2.  You may be using JSTL, but it still looks like
> scripting to
> > me.
> 
> Fair enough. What's your recommended alternative to
> JSTL when using JSP for
> your view layer?
> 
> > 3.  Strictly speaking, JavaBeans do not contain a
> constructor and
> > implement Serializable.
> 
> Strictly speaking, a JavaBean *does* contain a
> construtctor (or even more
> than one), just like any other Java class. It's just
> that a "real" bean
> needs to have a no-arg constructor. The actual code
> that I uploaded to Rick
> includes a no-arg construtctor for EmployeeBean but
> omitted implementing
> Serializable or Externalizable. The bean also fails
> to act as an event
> source and it doesn't check for things like null
> values passed to either its
> construtctor or its set methods.
> 
> > Mark
> > 
> > -Original Message-
> > From: Rick Reumann [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, July 15, 2003 11:44 PM
> > To: Struts Users Mailing List
> > Subject: [OT] Re: 4th Of July Struts Challenge...
> > 
> > 
> > Kris... this was just awesome! Thanks. You da
> 'man:)
> > 
> > On Tue, Jul 15,'03 (11:25 AM GMT-0400), Kris
> wrote:
> > 
> > > As it turns out, some of my ideas about a
> "standard" property of
> > > type
> > > Map versus a "mapped property" were a bit off.
> So, if you're still
> > > interested, here's something I hacked together.
> You'll notice I used a
> > > session scoped form so that Struts doesn't choke
> when it tries to
> > > populate the form.
> > > 
> > > struts-config.xml:
> > > --
> > > 
> > > 
> > >  > >   
> type="org.apache.struts.action.DynaActionForm">
> > >  type="java.util.Map"/>
> > > 
> > > 
> > > 
> > > 
> > >  > >
> type="com.dotech.EditEmployeesAction"
> > > name="employeesForm"
> > > scope="session"
> > > validate="false">
> > >  path="/editEmployees.jsp"/>
> > > 
> > >  > >
> type="org.apache.struts.actions.ForwardAction"
> > > parameter="/viewEmployees.jsp"
> > > name="employeesForm"
> > > scope="session"
> > > validate="false"/>
> >

RE: [OT] Re: 4th Of July Struts Challenge...

2003-07-16 Thread Michael Duffy

It's my understanding that you ONLY get the default if
there are no other constructors written.  The minute
you write ANY constructor, you're on your own.  If you
still want a default ctor, you've gotta supply it. 

I'll be happy to learn something if this is incorrect.
- MOD


--- Mark Galbreath <[EMAIL PROTECTED]> wrote:
> The no-argument constructor is the default and does
> not have to be declared.
> You have a 2-arg constructor.  As for JSTL (or any
> EL) acting like straight
> scripting, I've never had an argument with using
> scripting where
> appropriate.  Pragmatism should be the rule of the
> day.  Finally, I don't
> know why declaring DynaActionForm beans as Maps
> didn't work for me, but
> neither is it a big issue. I realize the constraints
> of declaring a variable
> as a concrete/abstract class vs. as an interface.
> 
> Besides, I like what you've created. :-)
> 
> -Original Message-
> From: Kris Schneider [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, July 16, 2003 8:55 AM
> To: Struts Users Mailing List
> Subject: RE: [OT] Re: 4th Of July Struts
> Challenge...
> 
> 
> Quoting Mark Galbreath <[EMAIL PROTECTED]>:
> 
> > A few comments:
> > 
> > 1.  I got runtime errors when I declared a
> DynaActionForm bean of type 
> > Map; I had to declare it of type HashMap.
> 
> Not sure what you're doing, but the example works as
> coded. If it matters,
> post some details and we'll see if something needs
> fixing.
> 
> > 2.  You may be using JSTL, but it still looks like
> scripting to 
> > me.
> 
> Fair enough. What's your recommended alternative to
> JSTL when using JSP for
> your view layer?
> 
> > 3.  Strictly speaking, JavaBeans do not contain a
> constructor and 
> > implement Serializable.
> 
> Strictly speaking, a JavaBean *does* contain a
> construtctor (or even more
> than one), just like any other Java class. It's just
> that a "real" bean
> needs to have a no-arg constructor. The actual code
> that I uploaded to Rick
> includes a no-arg construtctor for EmployeeBean but
> omitted implementing
> Serializable or Externalizable. The bean also fails
> to act as an event
> source and it doesn't check for things like null
> values passed to either its
> construtctor or its set methods.
> 
> > Mark
> > 
> > -Original Message-
> > From: Rick Reumann [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, July 15, 2003 11:44 PM
> > To: Struts Users Mailing List
> > Subject: [OT] Re: 4th Of July Struts Challenge...
> > 
> > 
> > Kris... this was just awesome! Thanks. You da
> 'man:)
> > 
> > On Tue, Jul 15,'03 (11:25 AM GMT-0400), Kris
> wrote:
> > 
> > > As it turns out, some of my ideas about a
> "standard" property of 
> > > type
> > > Map versus a "mapped property" were a bit off.
> So, if you're still 
> > > interested, here's something I hacked together.
> You'll notice I used a 
> > > session scoped form so that Struts doesn't choke
> when it tries to 
> > > populate the form.
> > > 
> > > struts-config.xml:
> > > --
> > > 
> > > 
> > >  > >   
> type="org.apache.struts.action.DynaActionForm">
> > >  type="java.util.Map"/>
> > > 
> > > 
> > > 
> > > 
> > >  > >
> type="com.dotech.EditEmployeesAction"
> > > name="employeesForm"
> > > scope="session"
> > > validate="false">
> > >  path="/editEmployees.jsp"/>
> > > 
> > >  > >
> type="org.apache.struts.actions.ForwardAction"
> > > parameter="/viewEmployees.jsp"
> > > name="employeesForm"
> > > scope="session"
> > > validate="false"/>
> > > 
> > > 
> > > 
> > > editEmployees.jsp:
> > > --
> > > 
> > > <%@ taglib prefix="bean"
> > > uri="http://jakarta.apache.org/struts/tags-bean";
> %><%@ taglib
> > > prefix="c"   
> uri="http://java.sun.com/jstl/core"; %><%@ taglib
> > &

RE: [OT] Re: 4th Of July Struts Challenge...

2003-07-16 Thread Mark Galbreath
The no-argument constructor is the default and does not have to be declared.
You have a 2-arg constructor.  As for JSTL (or any EL) acting like straight
scripting, I've never had an argument with using scripting where
appropriate.  Pragmatism should be the rule of the day.  Finally, I don't
know why declaring DynaActionForm beans as Maps didn't work for me, but
neither is it a big issue. I realize the constraints of declaring a variable
as a concrete/abstract class vs. as an interface.

Besides, I like what you've created. :-)

-Original Message-
From: Kris Schneider [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 16, 2003 8:55 AM
To: Struts Users Mailing List
Subject: RE: [OT] Re: 4th Of July Struts Challenge...


Quoting Mark Galbreath <[EMAIL PROTECTED]>:

> A few comments:
> 
> 1.  I got runtime errors when I declared a DynaActionForm bean of type 
> Map; I had to declare it of type HashMap.

Not sure what you're doing, but the example works as coded. If it matters,
post some details and we'll see if something needs fixing.

> 2.  You may be using JSTL, but it still looks like scripting to 
> me.

Fair enough. What's your recommended alternative to JSTL when using JSP for
your view layer?

> 3.  Strictly speaking, JavaBeans do not contain a constructor and 
> implement Serializable.

Strictly speaking, a JavaBean *does* contain a construtctor (or even more
than one), just like any other Java class. It's just that a "real" bean
needs to have a no-arg constructor. The actual code that I uploaded to Rick
includes a no-arg construtctor for EmployeeBean but omitted implementing
Serializable or Externalizable. The bean also fails to act as an event
source and it doesn't check for things like null values passed to either its
construtctor or its set methods.

> Mark
> 
> -Original Message-
> From: Rick Reumann [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, July 15, 2003 11:44 PM
> To: Struts Users Mailing List
> Subject: [OT] Re: 4th Of July Struts Challenge...
> 
> 
> Kris... this was just awesome! Thanks. You da 'man:)
> 
> On Tue, Jul 15,'03 (11:25 AM GMT-0400), Kris wrote:
> 
> > As it turns out, some of my ideas about a "standard" property of 
> > type
> > Map versus a "mapped property" were a bit off. So, if you're still 
> > interested, here's something I hacked together. You'll notice I used a 
> > session scoped form so that Struts doesn't choke when it tries to 
> > populate the form.
> > 
> > struts-config.xml:
> > --
> > 
> > 
> >  >type="org.apache.struts.action.DynaActionForm">
> > 
> > 
> > 
> > 
> > 
> >  > type="com.dotech.EditEmployeesAction"
> > name="employeesForm"
> > scope="session"
> > validate="false">
> > 
> > 
> >  > type="org.apache.struts.actions.ForwardAction"
> > parameter="/viewEmployees.jsp"
> > name="employeesForm"
> > scope="session"
> > validate="false"/>
> > 
> > 
> > 
> > editEmployees.jsp:
> > --
> > 
> > <%@ taglib prefix="bean"
> > uri="http://jakarta.apache.org/struts/tags-bean"; %><%@ taglib
> > prefix="c"uri="http://java.sun.com/jstl/core"; %><%@ taglib
> > prefix="html" uri="http://jakarta.apache.org/struts/tags-html"; %>
> > 
> > <%-- dynamically get a handle to the form --%>
> >   > var="attribute" value="${mapping.attribute}"/>  > value="${mapping.scope}"/> 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> >   Edit Employees
> > 
> >   
> > 
> >   
> > 
> >   
> > 
> > 
> >>  name=" >  value="employeesMap(${entry.key}).name"/>"
> >  value="">
> > 
> > 
> >>  name=" >  value="employeesMap(${entry.key}).age"/>"
> >  value=""

RE: [OT] Re: 4th Of July Struts Challenge...

2003-07-16 Thread Mark Galbreath
put a "do" before "implement" and ELs are just scripting in disguise.

Bloody Aussie.

-Original Message-
From: Andrew Hill [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 16, 2003 8:23 AM
To: Struts Users Mailing List
Subject: RE: [OT] Re: 4th Of July Struts Challenge...



Strictly speaking, JavaBeans do not contain a constructor and implement
Serializable. 

Dont they just need to make sure a noargs constructor is available?

Are they allowed to implement serializable if they want though? Be kinda
funny if they couldnt...

I wouldnt count expression evaluation languages as scripting myself. I
reckon to be a script you need to be able to script stuff (in addition to
having some kind of expression syntax): ie: do this and this and this...
whereas an expression is merely a statement of value.
Ie: a script would be "add 1 + 1 and get the result" whereas an expression
is merely "the value of 1 + 1".

I guess you've been using LISP too long to understand the difference eh? ;->

-Original Message-
From: Mark Galbreath [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 16 July 2003 20:12
To: 'Struts Users Mailing List'
Subject: RE: [OT] Re: 4th Of July Struts Challenge...


A few comments:

1.  I got runtime errors when I declared a DynaActionForm bean of type Map;
I had to declare it of type HashMap.

2.  You may be using JSTL, but it still looks like scripting to me.

3.  Strictly speaking, JavaBeans do not contain a constructor and implement
Serializable.

Mark

-Original Message-
From: Rick Reumann [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2003 11:44 PM
To: Struts Users Mailing List
Subject: [OT] Re: 4th Of July Struts Challenge...


Kris... this was just awesome! Thanks. You da 'man:)

On Tue, Jul 15,'03 (11:25 AM GMT-0400), Kris wrote:

> As it turns out, some of my ideas about a "standard" property of type 
> Map versus a "mapped property" were a bit off. So, if you're still 
> interested, here's something I hacked together. You'll notice I used a 
> session scoped form so that Struts doesn't choke when it tries to 
> populate the form.
>
> struts-config.xml:
> --
>
> 
> type="org.apache.struts.action.DynaActionForm">
> 
> 
> 
>
> 
>  type="com.dotech.EditEmployeesAction"
> name="employeesForm"
> scope="session"
> validate="false">
> 
> 
>  type="org.apache.struts.actions.ForwardAction"
> parameter="/viewEmployees.jsp"
> name="employeesForm"
> scope="session"
> validate="false"/>
> 
>
>
> editEmployees.jsp:
> --
>
> <%@ taglib prefix="bean" 
> uri="http://jakarta.apache.org/struts/tags-bean"; %><%@ taglib
> prefix="c"uri="http://java.sun.com/jstl/core"; %><%@ taglib
> prefix="html" uri="http://jakarta.apache.org/struts/tags-html"; %>
>
> <%-- dynamically get a handle to the form --%>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>
> 
>
>   Edit Employees
>
>   
> 
>   
> 
>   
> 
> 
> name="  value="employeesMap(${entry.key}).name"/>"
>  value="">
> 
> 
> name="  value="employeesMap(${entry.key}).age"/>"
>  value="">
> 
>   
> 
> 
>   
> 
>   
> 
>   
>
> 
>
>
> EmployeeBean.java:
> --
>
> package com.dotech;
>
> public class EmployeeBean {
>
> private String name;
> private String age;
>
> public EmployeeBean(String name, String age) {
> this.name = name;
> this.age = age;
> }
>
> public String getName() { return this.name; }
> public void setName(String name) { this.name = name; }
>
> public String getAge() { return this.age; }
> public void setAge(String age) { this.age = age; }
> }
>
>
> EditEmployeesAction.java:
> -
>
> package com.dotech;
>
> import java.util.*;
> import javax.servlet.http.*;
>

RE: [OT] Re: 4th Of July Struts Challenge...

2003-07-16 Thread Kris Schneider
Quoting Mark Galbreath <[EMAIL PROTECTED]>:

> A few comments:
> 
> 1.  I got runtime errors when I declared a DynaActionForm bean of type Map;
> I had to declare it of type HashMap.

Not sure what you're doing, but the example works as coded. If it matters, post
some details and we'll see if something needs fixing.

> 2.  You may be using JSTL, but it still looks like scripting to me.

Fair enough. What's your recommended alternative to JSTL when using JSP for your
view layer?

> 3.  Strictly speaking, JavaBeans do not contain a constructor and implement
> Serializable.

Strictly speaking, a JavaBean *does* contain a construtctor (or even more than
one), just like any other Java class. It's just that a "real" bean needs to have
a no-arg constructor. The actual code that I uploaded to Rick includes a no-arg
construtctor for EmployeeBean but omitted implementing Serializable or
Externalizable. The bean also fails to act as an event source and it doesn't
check for things like null values passed to either its construtctor or its set
methods.

> Mark
> 
> -Original Message-
> From: Rick Reumann [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, July 15, 2003 11:44 PM
> To: Struts Users Mailing List
> Subject: [OT] Re: 4th Of July Struts Challenge...
> 
> 
> Kris... this was just awesome! Thanks. You da 'man:)
> 
> On Tue, Jul 15,'03 (11:25 AM GMT-0400), Kris wrote: 
> 
> > As it turns out, some of my ideas about a "standard" property of type 
> > Map versus a "mapped property" were a bit off. So, if you're still 
> > interested, here's something I hacked together. You'll notice I used a 
> > session scoped form so that Struts doesn't choke when it tries to 
> > populate the form.
> > 
> > struts-config.xml:
> > --
> > 
> > 
> >  >type="org.apache.struts.action.DynaActionForm">
> > 
> > 
> > 
> > 
> > 
> >  > type="com.dotech.EditEmployeesAction"
> > name="employeesForm"
> > scope="session"
> > validate="false">
> > 
> > 
> >  > type="org.apache.struts.actions.ForwardAction"
> > parameter="/viewEmployees.jsp"
> > name="employeesForm"
> > scope="session"
> > validate="false"/>
> > 
> > 
> > 
> > editEmployees.jsp:
> > --
> > 
> > <%@ taglib prefix="bean" 
> > uri="http://jakarta.apache.org/struts/tags-bean"; %><%@ taglib
> > prefix="c"uri="http://java.sun.com/jstl/core"; %><%@ taglib
> > prefix="html" uri="http://jakarta.apache.org/struts/tags-html"; %>
> > 
> > <%-- dynamically get a handle to the form --%>
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> >   Edit Employees
> > 
> >   
> > 
> >   
> > 
> >   
> > 
> > 
> >>  name=" >  value="employeesMap(${entry.key}).name"/>"
> >  value="">
> > 
> > 
> >>  name=" >  value="employeesMap(${entry.key}).age"/>"
> >  value="">
> > 
> >   
> > 
> > 
> >   
> > 
> >   
> > 
> >   
> > 
> > 
> > 
> > 
> > EmployeeBean.java:
> > --
> > 
> > package com.dotech;
> > 
> > public class EmployeeBean {
> > 
> > private String name;
> > private String age;
> > 
> > public EmployeeBean(String name, String age) {
> > this.name = name;
> > this.age = age;
> > }
> > 
> > public String getName() { return this.name; }
> > public void setName(String name) { this.name = name; }
> > 
> > public String getAge() { return this.age; }
> > public void setAge(String age) { this.ag

RE: [OT] Re: 4th Of July Struts Challenge...

2003-07-16 Thread Andrew Hill

Strictly speaking, JavaBeans do not contain a constructor and implement
Serializable.


Dont they just need to make sure a noargs constructor is available?

Are they allowed to implement serializable if they want though? Be kinda
funny if they couldnt...

I wouldnt count expression evaluation languages as scripting myself. I
reckon to be a script you need to be able to script stuff (in addition to
having some kind of expression syntax): ie: do this and this and this...
whereas an expression is merely a statement of value.
Ie: a script would be "add 1 + 1 and get the result" whereas an expression
is merely "the value of 1 + 1".

I guess you've been using LISP too long to understand the difference eh? ;->

-Original Message-
From: Mark Galbreath [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 16 July 2003 20:12
To: 'Struts Users Mailing List'
Subject: RE: [OT] Re: 4th Of July Struts Challenge...


A few comments:

1.  I got runtime errors when I declared a DynaActionForm bean of type Map;
I had to declare it of type HashMap.

2.  You may be using JSTL, but it still looks like scripting to me.

3.  Strictly speaking, JavaBeans do not contain a constructor and implement
Serializable.

Mark

-Original Message-
From: Rick Reumann [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2003 11:44 PM
To: Struts Users Mailing List
Subject: [OT] Re: 4th Of July Struts Challenge...


Kris... this was just awesome! Thanks. You da 'man:)

On Tue, Jul 15,'03 (11:25 AM GMT-0400), Kris wrote:

> As it turns out, some of my ideas about a "standard" property of type
> Map versus a "mapped property" were a bit off. So, if you're still
> interested, here's something I hacked together. You'll notice I used a
> session scoped form so that Struts doesn't choke when it tries to
> populate the form.
>
> struts-config.xml:
> --
>
> 
> type="org.apache.struts.action.DynaActionForm">
> 
> 
> 
>
> 
>  type="com.dotech.EditEmployeesAction"
> name="employeesForm"
> scope="session"
> validate="false">
> 
> 
>  type="org.apache.struts.actions.ForwardAction"
> parameter="/viewEmployees.jsp"
> name="employeesForm"
> scope="session"
> validate="false"/>
> 
>
>
> editEmployees.jsp:
> --
>
> <%@ taglib prefix="bean"
> uri="http://jakarta.apache.org/struts/tags-bean"; %><%@ taglib
> prefix="c"uri="http://java.sun.com/jstl/core"; %><%@ taglib
> prefix="html" uri="http://jakarta.apache.org/struts/tags-html"; %>
>
> <%-- dynamically get a handle to the form --%>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>
> 
>
>   Edit Employees
>
>   
> 
>   
> 
>   
> 
> 
> name="  value="employeesMap(${entry.key}).name"/>"
>  value="">
> 
> 
> name="  value="employeesMap(${entry.key}).age"/>"
>  value="">
> 
>   
> 
> 
>   
> 
>   
> 
>   
>
> 
>
>
> EmployeeBean.java:
> --
>
> package com.dotech;
>
> public class EmployeeBean {
>
> private String name;
> private String age;
>
> public EmployeeBean(String name, String age) {
> this.name = name;
> this.age = age;
> }
>
> public String getName() { return this.name; }
> public void setName(String name) { this.name = name; }
>
> public String getAge() { return this.age; }
> public void setAge(String age) { this.age = age; }
> }
>
>
> EditEmployeesAction.java:
> -
>
> package com.dotech;
>
> import java.util.*;
> import javax.servlet.http.*;
> import org.apache.commons.beanutils.*;
> import org.apache.struts.action.*;
>
> public class EditEmployeesAction extends Action {
>
> public ActionForward execute(ActionMapping mapping,
>  ActionForm form,
>   

RE: [OT] Re: 4th Of July Struts Challenge...

2003-07-16 Thread Mark Galbreath
A few comments:

1.  I got runtime errors when I declared a DynaActionForm bean of type Map;
I had to declare it of type HashMap.

2.  You may be using JSTL, but it still looks like scripting to me.

3.  Strictly speaking, JavaBeans do not contain a constructor and implement
Serializable.

Mark

-Original Message-
From: Rick Reumann [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 15, 2003 11:44 PM
To: Struts Users Mailing List
Subject: [OT] Re: 4th Of July Struts Challenge...


Kris... this was just awesome! Thanks. You da 'man:)

On Tue, Jul 15,'03 (11:25 AM GMT-0400), Kris wrote: 

> As it turns out, some of my ideas about a "standard" property of type 
> Map versus a "mapped property" were a bit off. So, if you're still 
> interested, here's something I hacked together. You'll notice I used a 
> session scoped form so that Struts doesn't choke when it tries to 
> populate the form.
> 
> struts-config.xml:
> --
> 
> 
> type="org.apache.struts.action.DynaActionForm">
> 
> 
> 
> 
> 
>  type="com.dotech.EditEmployeesAction"
> name="employeesForm"
> scope="session"
> validate="false">
> 
> 
>  type="org.apache.struts.actions.ForwardAction"
> parameter="/viewEmployees.jsp"
> name="employeesForm"
> scope="session"
> validate="false"/>
> 
> 
> 
> editEmployees.jsp:
> --
> 
> <%@ taglib prefix="bean" 
> uri="http://jakarta.apache.org/struts/tags-bean"; %><%@ taglib
> prefix="c"uri="http://java.sun.com/jstl/core"; %><%@ taglib
> prefix="html" uri="http://jakarta.apache.org/struts/tags-html"; %>
> 
> <%-- dynamically get a handle to the form --%>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>   Edit Employees
> 
>   
> 
>   
> 
>   
> 
> 
> name="  value="employeesMap(${entry.key}).name"/>"
>  value="">
> 
> 
> name="  value="employeesMap(${entry.key}).age"/>"
>  value="">
> 
>   
> 
> 
>   
> 
>   
> 
>   
> 
> 
> 
> 
> EmployeeBean.java:
> --
> 
> package com.dotech;
> 
> public class EmployeeBean {
> 
> private String name;
> private String age;
> 
> public EmployeeBean(String name, String age) {
> this.name = name;
> this.age = age;
> }
> 
> public String getName() { return this.name; }
> public void setName(String name) { this.name = name; }
> 
> public String getAge() { return this.age; }
> public void setAge(String age) { this.age = age; }
> }
> 
> 
> EditEmployeesAction.java:
> -
> 
> package com.dotech;
> 
> import java.util.*;
> import javax.servlet.http.*;
> import org.apache.commons.beanutils.*;
> import org.apache.struts.action.*;
> 
> public class EditEmployeesAction extends Action {
> 
> public ActionForward execute(ActionMapping mapping,
>  ActionForm form,
>  HttpServletRequest request,
>  HttpServletResponse response) throws
>  Exception {
> Map empMap = new HashMap();
> empMap.put("", new EmployeeBean("John Doe", "33"));
> empMap.put("", new EmployeeBean("Loser Boy", "22"));
> PropertyUtils.setProperty(form, "employeesMap", empMap);
> return mapping.findForward("success");
> }
> }
> 
> 
> viewEmployees.jsp:
> --
> 
> <%@ taglib prefix="bean" 
> uri="http://jakarta.apache.org/struts/tags-bean"; %><%@ taglib
> prefix="c"uri="http://java.sun.com/jstl/core"; %>
> 
> <%-- dynamically get a handle to the form --%>
> 
> 
> 
> 
> 
> 
>

[OT] Re: 4th Of July Struts Challenge...

2003-07-15 Thread Rick Reumann
Kris... this was just awesome! Thanks. You da 'man:)

On Tue, Jul 15,'03 (11:25 AM GMT-0400), Kris wrote: 

> As it turns out, some of my ideas about a "standard" property of type
> Map versus a "mapped property" were a bit off. So, if you're still
> interested, here's something I hacked together. You'll notice I used a
> session scoped form so that Struts doesn't choke when it tries to
> populate the form.
> 
> struts-config.xml:
> --
> 
> 
> type="org.apache.struts.action.DynaActionForm">
> 
> 
> 
> 
> 
>  type="com.dotech.EditEmployeesAction"
> name="employeesForm"
> scope="session"
> validate="false">
> 
> 
>  type="org.apache.struts.actions.ForwardAction"
> parameter="/viewEmployees.jsp"
> name="employeesForm"
> scope="session"
> validate="false"/>
> 
> 
> 
> editEmployees.jsp:
> --
> 
> <%@ taglib prefix="bean"
> uri="http://jakarta.apache.org/struts/tags-bean"; %><%@ taglib
> prefix="c"uri="http://java.sun.com/jstl/core"; %><%@ taglib
> prefix="html" uri="http://jakarta.apache.org/struts/tags-html"; %>
> 
> <%-- dynamically get a handle to the form --%>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>   Edit Employees
> 
>   
> 
>   
> 
>   
> 
> 
> name="  value="employeesMap(${entry.key}).name"/>"
>  value="">
> 
> 
> name="  value="employeesMap(${entry.key}).age"/>"
>  value="">
> 
>   
> 
> 
>   
> 
>   
> 
>   
> 
> 
> 
> 
> EmployeeBean.java:
> --
> 
> package com.dotech;
> 
> public class EmployeeBean {
> 
> private String name;
> private String age;
> 
> public EmployeeBean(String name, String age) {
> this.name = name;
> this.age = age;
> }
> 
> public String getName() { return this.name; }
> public void setName(String name) { this.name = name; }
> 
> public String getAge() { return this.age; }
> public void setAge(String age) { this.age = age; }
> }
> 
> 
> EditEmployeesAction.java:
> -
> 
> package com.dotech;
> 
> import java.util.*;
> import javax.servlet.http.*;
> import org.apache.commons.beanutils.*;
> import org.apache.struts.action.*;
> 
> public class EditEmployeesAction extends Action {
> 
> public ActionForward execute(ActionMapping mapping,
>  ActionForm form,
>  HttpServletRequest request,
>  HttpServletResponse response) throws
>  Exception {
> Map empMap = new HashMap();
> empMap.put("", new EmployeeBean("John Doe", "33"));
> empMap.put("", new EmployeeBean("Loser Boy", "22"));
> PropertyUtils.setProperty(form, "employeesMap", empMap);
> return mapping.findForward("success");
> }
> }
> 
> 
> viewEmployees.jsp:
> --
> 
> <%@ taglib prefix="bean"
> uri="http://jakarta.apache.org/struts/tags-bean"; %><%@ taglib
> prefix="c"uri="http://java.sun.com/jstl/core"; %>
> 
> <%-- dynamically get a handle to the form --%>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> View Employees
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Quoting Kris Schneider <[EMAIL PROTECTED]>:
> 
> > Okay, so that's way too much work ;-). I'm not sure, but I think one
> > of the issues you're running into is the difference between a
> > "standard" property of
> > type Map and a "mapped property". The first is declared like:
> > 
> > public Map getEmployeesMap()
> > public void setEmployeesMap(Map m)
> > 
> > The second is declared like:
> > 
> > public Object getEmployeeMapped(String key)
> > public void setEmployeeMapped(String key, Object value)
> > 
> > For a mapped property, you'd use a reference like
> > "employeeMapped()" to get
> > the object stored under the "" key. I really haven't played much
> > with either
> > of the above cases, so I may be off base...
> > 
> > Quoting Rick Reumann <[EMAIL PROTECTED]>:
> > 
> > > Ok stupid subject line, but now I can get back to something I was
> > > curious about that I posted around a week ago. I'm really curious
> > > how to do accomplish this and yes have tried it a bunch of
> > > different ways... 
> > > 
> > > Here's the challenge
> > > 
> > > First challenge is just with a regular ActionForm...
> > > 
> > > 

Re: 4th Of July Struts Challenge...

2003-07-15 Thread Kris Schneider
As it turns out, some of my ideas about a "standard" property of type Map versus
a "mapped property" were a bit off. So, if you're still interested, here's
something I hacked together. You'll notice I used a session scoped form so that
Struts doesn't choke when it tries to populate the form.

struts-config.xml:
--















editEmployees.jsp:
--

<%@ taglib prefix="bean" uri="http://jakarta.apache.org/struts/tags-bean"; %>
<%@ taglib prefix="c"uri="http://java.sun.com/jstl/core"; %>
<%@ taglib prefix="html" uri="http://jakarta.apache.org/struts/tags-html"; %>

<%-- dynamically get a handle to the form --%>














  Edit Employees

  

  

  


  " 
 value="">


  " 
 value="">

  


  

  

  




EmployeeBean.java:
--

package com.dotech;

public class EmployeeBean {

private String name;
private String age;

public EmployeeBean(String name, String age) {
this.name = name;
this.age = age;
}

public String getName() { return this.name; }
public void setName(String name) { this.name = name; }

public String getAge() { return this.age; }
public void setAge(String age) { this.age = age; }
}


EditEmployeesAction.java:
-

package com.dotech;

import java.util.*;
import javax.servlet.http.*;
import org.apache.commons.beanutils.*;
import org.apache.struts.action.*;

public class EditEmployeesAction extends Action {

public ActionForward execute(ActionMapping mapping,
 ActionForm form,
 HttpServletRequest request,
 HttpServletResponse response) throws Exception {
Map empMap = new HashMap();
empMap.put("", new EmployeeBean("John Doe", "33"));
empMap.put("", new EmployeeBean("Loser Boy", "22"));
PropertyUtils.setProperty(form, "employeesMap", empMap);
return mapping.findForward("success");
}
}


viewEmployees.jsp:
--

<%@ taglib prefix="bean" uri="http://jakarta.apache.org/struts/tags-bean"; %>
<%@ taglib prefix="c"uri="http://java.sun.com/jstl/core"; %>

<%-- dynamically get a handle to the form --%>














View Employees















Quoting Kris Schneider <[EMAIL PROTECTED]>:

> Okay, so that's way too much work ;-). I'm not sure, but I think one of the
> issues you're running into is the difference between a "standard" property
> of
> type Map and a "mapped property". The first is declared like:
> 
> public Map getEmployeesMap()
> public void setEmployeesMap(Map m)
> 
> The second is declared like:
> 
> public Object getEmployeeMapped(String key)
> public void setEmployeeMapped(String key, Object value)
> 
> For a mapped property, you'd use a reference like "employeeMapped()" to
> get
> the object stored under the "" key. I really haven't played much with
> either
> of the above cases, so I may be off base...
> 
> Quoting Rick Reumann <[EMAIL PROTECTED]>:
> 
> > Ok stupid subject line, but now I can get back to something I was
> > curious about that I posted around a week ago. I'm really curious how to
> > do accomplish this and yes have tried it a bunch of different ways... 
> > 
> > Here's the challenge
> > 
> > First challenge is just with a regular ActionForm...
> > 
> > 1) Your ActionForm has to have a property of type Map. For this
> > adventure call it employeesMap.
> > 
> > 2) Each map will hold for the key and employeeID ( String ssn - social
> > security number whatever). The value will be an EmployeeBean. For
> > testing sake just have it have two properties String name, String age.
> > 
> > 3) Put two employees into the Map and put this Map into your ActionForm:
> > HashMap empMap = new HashMap();
> > empMap.put( "", new EmployeeBean("John Doe", "33" ) );
> > empMap.put( "", new EmployeeBean("Loser Boy", "22" ) );
> > setEmployeesMap( empMap );
> > 
> > 4) Now have a jsp form iterate over this Map and provide text fields to
> > edit the name and age of each employee. When the form is submitted there
> > should be a way that it will submit this Map with updated EmployeeBeans
> > with the new names and ages for each key ( and  ). Pull the map
> > out of the action you submit to and print the properties of the
> > EmployeeBeans to test.
> > 
> > 
> > Second challenge... is do the above using your employeesMap as a
> > property of a DynaActionForm.
> > 
> > Preferably use JSTL and/or struts

Re: 4th Of July Struts Challenge...

2003-07-04 Thread Sandeep Takhar
The answer for the first part is here:

http://www.mail-archive.com/[EMAIL PROTECTED]/msg71256.html

specifically the part where it talks about nested tags
works.  The logic:iterate I couldn't get to work and I
haven't set up the el stuff, but that would probably
work.

All you need in the form is the Object getMap(String
key) and setMap(key,object)

next thing to try is the dynaform, but I've never used
one before...

sandeep
--- Rick Reumann <[EMAIL PROTECTED]> wrote:
> Ok stupid subject line, but now I can get back to
> something I was
> curious about that I posted around a week ago. I'm
> really curious how to
> do accomplish this and yes have tried it a bunch of
> different ways... 
> 
> Here's the challenge
> 
> First challenge is just with a regular ActionForm...
> 
> 1) Your ActionForm has to have a property of type
> Map. For this
> adventure call it employeesMap.
> 
> 2) Each map will hold for the key and employeeID (
> String ssn - social
> security number whatever). The value will be an
> EmployeeBean. For
> testing sake just have it have two properties String
> name, String age.
> 
> 3) Put two employees into the Map and put this Map
> into your ActionForm:
> HashMap empMap = new HashMap();
> empMap.put( "", new EmployeeBean("John Doe",
> "33" ) );
> empMap.put( "", new EmployeeBean("Loser Boy",
> "22" ) );
> setEmployeesMap( empMap );
> 
> 4) Now have a jsp form iterate over this Map and
> provide text fields to
> edit the name and age of each employee. When the
> form is submitted there
> should be a way that it will submit this Map with
> updated EmployeeBeans
> with the new names and ages for each key ( and
>  ). Pull the map
> out of the action you submit to and print the
> properties of the
> EmployeeBeans to test.
> 
> 
> Second challenge... is do the above using your
> employeesMap as a
> property of a DynaActionForm.
> 
> Preferably use JSTL and/or struts-el also would be
> nice.
> 
> (First one to successfully complete this challenge
> will win 100 dollars
> for each person that they forward this e-mail to, as
> Microsoft will be
> monitoring all the e-mails as well. That kid doing
> this project for his
> science fair project to see how far e-mails travel
> will also be
> involved, so please reply to him. The 100 dollars
> will come from that
> African tribe leader with that money he is just
> dying to give away if
> you just contact him. Some of the money might come
> from the stolen
> tourist kidney sales in Mexico, but I'm not positive
> of that).
> 
> -- 
> Rick 
> 
> 
>
-
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 


__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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



RE: 4th Of July Struts Challenge...

2003-07-03 Thread Mark Galbreath
nnection conn = ds.getConnection();
Statement stmt = conn.createStatement();

return( stmt.executeUpdate( sql ) );

} catch( NamingException e ) {
        System.out.println( "JNDI lookup error: " +
e.getMessage() );

} catch( SQLException e ) {
System.out.println( "Error connecting to database: "
+ e.getMessage() );
}
return( 0 );
}
}

-Original Message-
From: Rick Reumann [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 03, 2003 2:03 PM
To: Struts Users Mailing List
Subject: 4th Of July Struts Challenge...


Ok stupid subject line, but now I can get back to something I was curious
about that I posted around a week ago. I'm really curious how to do
accomplish this and yes have tried it a bunch of different ways... 

Here's the challenge

First challenge is just with a regular ActionForm...

1) Your ActionForm has to have a property of type Map. For this adventure
call it employeesMap.

2) Each map will hold for the key and employeeID ( String ssn - social
security number whatever). The value will be an EmployeeBean. For testing
sake just have it have two properties String name, String age.

3) Put two employees into the Map and put this Map into your ActionForm:
HashMap empMap = new HashMap(); empMap.put( "", new EmployeeBean("John
Doe", "33" ) ); empMap.put( "", new EmployeeBean("Loser Boy", "22" ) );
setEmployeesMap( empMap );

4) Now have a jsp form iterate over this Map and provide text fields to edit
the name and age of each employee. When the form is submitted there should
be a way that it will submit this Map with updated EmployeeBeans with the
new names and ages for each key ( and  ). Pull the map out of the
action you submit to and print the properties of the EmployeeBeans to test.


Second challenge... is do the above using your employeesMap as a property of
a DynaActionForm.

Preferably use JSTL and/or struts-el also would be nice.

(First one to successfully complete this challenge will win 100 dollars for
each person that they forward this e-mail to, as Microsoft will be
monitoring all the e-mails as well. That kid doing this project for his
science fair project to see how far e-mails travel will also be involved, so
please reply to him. The 100 dollars will come from that African tribe
leader with that money he is just dying to give away if you just contact
him. Some of the money might come from the stolen tourist kidney sales in
Mexico, but I'm not positive of that).

-- 
Rick 


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



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



Re: 4th Of July Struts Challenge...

2003-07-03 Thread Kris Schneider
Okay, so that's way too much work ;-). I'm not sure, but I think one of the
issues you're running into is the difference between a "standard" property of
type Map and a "mapped property". The first is declared like:

public Map getEmployeesMap()
public void setEmployeesMap(Map m)

The second is declared like:

public Object getEmployeeMapped(String key)
public void setEmployeeMapped(String key, Object value)

For a mapped property, you'd use a reference like "employeeMapped()" to get
the object stored under the "" key. I really haven't played much with either
of the above cases, so I may be off base...

Quoting Rick Reumann <[EMAIL PROTECTED]>:

> Ok stupid subject line, but now I can get back to something I was
> curious about that I posted around a week ago. I'm really curious how to
> do accomplish this and yes have tried it a bunch of different ways... 
> 
> Here's the challenge
> 
> First challenge is just with a regular ActionForm...
> 
> 1) Your ActionForm has to have a property of type Map. For this
> adventure call it employeesMap.
> 
> 2) Each map will hold for the key and employeeID ( String ssn - social
> security number whatever). The value will be an EmployeeBean. For
> testing sake just have it have two properties String name, String age.
> 
> 3) Put two employees into the Map and put this Map into your ActionForm:
> HashMap empMap = new HashMap();
> empMap.put( "", new EmployeeBean("John Doe", "33" ) );
> empMap.put( "", new EmployeeBean("Loser Boy", "22" ) );
> setEmployeesMap( empMap );
> 
> 4) Now have a jsp form iterate over this Map and provide text fields to
> edit the name and age of each employee. When the form is submitted there
> should be a way that it will submit this Map with updated EmployeeBeans
> with the new names and ages for each key ( and  ). Pull the map
> out of the action you submit to and print the properties of the
> EmployeeBeans to test.
> 
> 
> Second challenge... is do the above using your employeesMap as a
> property of a DynaActionForm.
> 
> Preferably use JSTL and/or struts-el also would be nice.
> 
> (First one to successfully complete this challenge will win 100 dollars
> for each person that they forward this e-mail to, as Microsoft will be
> monitoring all the e-mails as well. That kid doing this project for his
> science fair project to see how far e-mails travel will also be
> involved, so please reply to him. The 100 dollars will come from that
> African tribe leader with that money he is just dying to give away if
> you just contact him. Some of the money might come from the stolen
> tourist kidney sales in Mexico, but I'm not positive of that).
> 
> -- 
> Rick 

-- 
Kris Schneider 
D.O.Tech   

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



4th Of July Struts Challenge...

2003-07-03 Thread Rick Reumann
Ok stupid subject line, but now I can get back to something I was
curious about that I posted around a week ago. I'm really curious how to
do accomplish this and yes have tried it a bunch of different ways... 

Here's the challenge

First challenge is just with a regular ActionForm...

1) Your ActionForm has to have a property of type Map. For this
adventure call it employeesMap.

2) Each map will hold for the key and employeeID ( String ssn - social
security number whatever). The value will be an EmployeeBean. For
testing sake just have it have two properties String name, String age.

3) Put two employees into the Map and put this Map into your ActionForm:
HashMap empMap = new HashMap();
empMap.put( "", new EmployeeBean("John Doe", "33" ) );
empMap.put( "", new EmployeeBean("Loser Boy", "22" ) );
setEmployeesMap( empMap );

4) Now have a jsp form iterate over this Map and provide text fields to
edit the name and age of each employee. When the form is submitted there
should be a way that it will submit this Map with updated EmployeeBeans
with the new names and ages for each key ( and  ). Pull the map
out of the action you submit to and print the properties of the
EmployeeBeans to test.


Second challenge... is do the above using your employeesMap as a
property of a DynaActionForm.

Preferably use JSTL and/or struts-el also would be nice.

(First one to successfully complete this challenge will win 100 dollars
for each person that they forward this e-mail to, as Microsoft will be
monitoring all the e-mails as well. That kid doing this project for his
science fair project to see how far e-mails travel will also be
involved, so please reply to him. The 100 dollars will come from that
African tribe leader with that money he is just dying to give away if
you just contact him. Some of the money might come from the stolen
tourist kidney sales in Mexico, but I'm not positive of that).

-- 
Rick 


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