You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Lieven De Keyzer <li...@hotmail.com> on 2005/05/13 01:51:56 UTC
[OT] JPetStore - BaseBean / BeanAction
I took the lastest JPetStore as a starting point for my application.
The problem I have now: I want to have multiple actions in one form. I have
a set of objects belonging to a user and this are displayed together with a
checkbox for each object. I want the users to be able to check a few boxes
and let them choose to delete those, or edit them all at once, etc...
Normall I think one should implement a class that inherits from the
DispatchAction Class.
I guess using the BaseBean and BeanAction class, this should even be
simpler. Should I use the same tactic as the DispatchAction class uses ?
Something like:
public Class TreeLevel extends BaseBean {
private String method;
public String formAction {
if (method == "foo") {
return foo(); }
else { return bar(); }
}
private String foo() {
//
}
private String bar() {
}
}
And then in my jsp page:
<html:form action="/formAction">
<html:submit property="method" value="foo" />
<html:submit property="method" value="bar" />
</html:form>
Re: [OT] JPetStore - BaseBean / BeanAction
Posted by Clinton Begin <cl...@gmail.com>.
Oh, my bad. I was considering the term "form" more loosely, as in the web
page in general. The way JPetStore handles it is by using multiple forms. If
you have a regular need for multiple actions per form, then you might have
to pioneer something and share it with us! It would be a grand addition to
the framework.
By the way, is anyone interested in suggesting this become a part of Struts,
perhaps in a "contrib" JAR or something? Is it good enough?
Cheers,
Clinton
On 5/13/05, Lieven De Keyzer <li...@hotmail.com> wrote:
>
> Yes, I realize this, but a form can only have one action specified I
> believe?
> So this method would need to have a case where other methods can be
> called?
>
> >From: Clinton Begin <cl...@gmail.com>
> >Reply-To: cbegin@ibatis.com
> >To: ibatis-user-java@incubator.apache.org
> >Subject: Re: [OT] JPetStore - BaseBean / BeanAction
> >Date: Thu, 12 May 2005 21:56:55 -0600
> >
> >It should be noted that JPetStore also performs multiple "actions" per
> >form.
> >The difference is that with BeanAction, you must call a different URL for
> >each "action". (I quote action, as there is obviously only one actual
> >Action
> >class...).
> >
> >Clinton
> >
> >
> >On 5/12/05, Lieven De Keyzer <li...@hotmail.com> wrote:
> > >
> > >
> > >
> > > >From: Brandon Goodin <br...@gmail.com>
> > > >Reply-To: Brandon Goodin <br...@gmail.com>
> > > >To: ibatis-user-java@incubator.apache.org
> > > >Subject: Re: [OT] JPetStore - BaseBean / BeanAction
> > > >Date: Thu, 12 May 2005 19:01:02 -0600
> > > >
> > > >i'm not sure about your "formAction" semantic. You should name it
> > > >something meaningful like "removeFoo". The method names should be
> > > >named after the actions that are taking place.
> > >
> > > Yes, I should have given my real problem instead of this one. But that
> > > would
> > > mean my action would be called: folderActions. And the methods foo and
> >bar
> > > would be: remove and edit.
> > >
> > > >But, yes you would follow the same semantic. You need to realize that
> > > >JPetstore is NOT
> > > >standard struts practice. It is a way to use struts in a more modern
> > > >manner (i.e. Action has properties on it rather than sepearate in an
> > > >ActionForm.).
> > >
> > > And I like this modern way better than the old one. :)
> > >
> > > >Otherwise, it sounds like you have the idea down fairly well.
> > > >
> > > >Brandon
> > > >
> > > >On 5/12/05, Lieven De Keyzer <li...@hotmail.com> wrote:
> > > > > I took the lastest JPetStore as a starting point for my
> application.
> > > > >
> > > > > The problem I have now: I want to have multiple actions in one
> form.
> >I
> > > >have
> > > > > a set of objects belonging to a user and this are displayed
> together
> > > >with a
> > > > > checkbox for each object. I want the users to be able to check a
> few
> > > >boxes
> > > > > and let them choose to delete those, or edit them all at once,
> >etc...
> > > > >
> > > > > Normall I think one should implement a class that inherits from
> the
> > > > > DispatchAction Class.
> > > > >
> > > > > I guess using the BaseBean and BeanAction class, this should even
> be
> > > > > simpler. Should I use the same tactic as the DispatchAction class
> >uses
> > > ?
> > > > > Something like:
> > > > >
> > > > > public Class TreeLevel extends BaseBean {
> > > > >
> > > > > private String method;
> > > > >
> > > > > public String formAction {
> > > > > if (method == "foo") {
> > > > > return foo(); }
> > > > > else { return bar(); }
> > > > > }
> > > > >
> > > > > private String foo() {
> > > > > //
> > > > > }
> > > > >
> > > > > private String bar() {
> > > > > }
> > > > > }
> > > > >
> > > > > And then in my jsp page:
> > > > >
> > > > > <html:form action="/formAction">
> > > > > <html:submit property="method" value="foo" />
> > > > > <html:submit property="method" value="bar" />
> > > > > </html:form>
> > > > >
> > > > >
> > >
> > >
>
>
Re: [OT] JPetStore - BaseBean / BeanAction
Posted by Lieven De Keyzer <li...@hotmail.com>.
Yes, I realize this, but a form can only have one action specified I
believe?
So this method would need to have a case where other methods can be called?
>From: Clinton Begin <cl...@gmail.com>
>Reply-To: cbegin@ibatis.com
>To: ibatis-user-java@incubator.apache.org
>Subject: Re: [OT] JPetStore - BaseBean / BeanAction
>Date: Thu, 12 May 2005 21:56:55 -0600
>
>It should be noted that JPetStore also performs multiple "actions" per
>form.
>The difference is that with BeanAction, you must call a different URL for
>each "action". (I quote action, as there is obviously only one actual
>Action
>class...).
>
>Clinton
>
>
>On 5/12/05, Lieven De Keyzer <li...@hotmail.com> wrote:
> >
> >
> >
> > >From: Brandon Goodin <br...@gmail.com>
> > >Reply-To: Brandon Goodin <br...@gmail.com>
> > >To: ibatis-user-java@incubator.apache.org
> > >Subject: Re: [OT] JPetStore - BaseBean / BeanAction
> > >Date: Thu, 12 May 2005 19:01:02 -0600
> > >
> > >i'm not sure about your "formAction" semantic. You should name it
> > >something meaningful like "removeFoo". The method names should be
> > >named after the actions that are taking place.
> >
> > Yes, I should have given my real problem instead of this one. But that
> > would
> > mean my action would be called: folderActions. And the methods foo and
>bar
> > would be: remove and edit.
> >
> > >But, yes you would follow the same semantic. You need to realize that
> > >JPetstore is NOT
> > >standard struts practice. It is a way to use struts in a more modern
> > >manner (i.e. Action has properties on it rather than sepearate in an
> > >ActionForm.).
> >
> > And I like this modern way better than the old one. :)
> >
> > >Otherwise, it sounds like you have the idea down fairly well.
> > >
> > >Brandon
> > >
> > >On 5/12/05, Lieven De Keyzer <li...@hotmail.com> wrote:
> > > > I took the lastest JPetStore as a starting point for my application.
> > > >
> > > > The problem I have now: I want to have multiple actions in one form.
>I
> > >have
> > > > a set of objects belonging to a user and this are displayed together
> > >with a
> > > > checkbox for each object. I want the users to be able to check a few
> > >boxes
> > > > and let them choose to delete those, or edit them all at once,
>etc...
> > > >
> > > > Normall I think one should implement a class that inherits from the
> > > > DispatchAction Class.
> > > >
> > > > I guess using the BaseBean and BeanAction class, this should even be
> > > > simpler. Should I use the same tactic as the DispatchAction class
>uses
> > ?
> > > > Something like:
> > > >
> > > > public Class TreeLevel extends BaseBean {
> > > >
> > > > private String method;
> > > >
> > > > public String formAction {
> > > > if (method == "foo") {
> > > > return foo(); }
> > > > else { return bar(); }
> > > > }
> > > >
> > > > private String foo() {
> > > > //
> > > > }
> > > >
> > > > private String bar() {
> > > > }
> > > > }
> > > >
> > > > And then in my jsp page:
> > > >
> > > > <html:form action="/formAction">
> > > > <html:submit property="method" value="foo" />
> > > > <html:submit property="method" value="bar" />
> > > > </html:form>
> > > >
> > > >
> >
> >
Re: [OT] JPetStore - BaseBean / BeanAction
Posted by Clinton Begin <cl...@gmail.com>.
It should be noted that JPetStore also performs multiple "actions" per form.
The difference is that with BeanAction, you must call a different URL for
each "action". (I quote action, as there is obviously only one actual Action
class...).
Clinton
On 5/12/05, Lieven De Keyzer <li...@hotmail.com> wrote:
>
>
>
> >From: Brandon Goodin <br...@gmail.com>
> >Reply-To: Brandon Goodin <br...@gmail.com>
> >To: ibatis-user-java@incubator.apache.org
> >Subject: Re: [OT] JPetStore - BaseBean / BeanAction
> >Date: Thu, 12 May 2005 19:01:02 -0600
> >
> >i'm not sure about your "formAction" semantic. You should name it
> >something meaningful like "removeFoo". The method names should be
> >named after the actions that are taking place.
>
> Yes, I should have given my real problem instead of this one. But that
> would
> mean my action would be called: folderActions. And the methods foo and bar
> would be: remove and edit.
>
> >But, yes you would follow the same semantic. You need to realize that
> >JPetstore is NOT
> >standard struts practice. It is a way to use struts in a more modern
> >manner (i.e. Action has properties on it rather than sepearate in an
> >ActionForm.).
>
> And I like this modern way better than the old one. :)
>
> >Otherwise, it sounds like you have the idea down fairly well.
> >
> >Brandon
> >
> >On 5/12/05, Lieven De Keyzer <li...@hotmail.com> wrote:
> > > I took the lastest JPetStore as a starting point for my application.
> > >
> > > The problem I have now: I want to have multiple actions in one form. I
> >have
> > > a set of objects belonging to a user and this are displayed together
> >with a
> > > checkbox for each object. I want the users to be able to check a few
> >boxes
> > > and let them choose to delete those, or edit them all at once, etc...
> > >
> > > Normall I think one should implement a class that inherits from the
> > > DispatchAction Class.
> > >
> > > I guess using the BaseBean and BeanAction class, this should even be
> > > simpler. Should I use the same tactic as the DispatchAction class uses
> ?
> > > Something like:
> > >
> > > public Class TreeLevel extends BaseBean {
> > >
> > > private String method;
> > >
> > > public String formAction {
> > > if (method == "foo") {
> > > return foo(); }
> > > else { return bar(); }
> > > }
> > >
> > > private String foo() {
> > > //
> > > }
> > >
> > > private String bar() {
> > > }
> > > }
> > >
> > > And then in my jsp page:
> > >
> > > <html:form action="/formAction">
> > > <html:submit property="method" value="foo" />
> > > <html:submit property="method" value="bar" />
> > > </html:form>
> > >
> > >
>
>
Re: [OT] JPetStore - BaseBean / BeanAction
Posted by Lieven De Keyzer <li...@hotmail.com>.
>From: Brandon Goodin <br...@gmail.com>
>Reply-To: Brandon Goodin <br...@gmail.com>
>To: ibatis-user-java@incubator.apache.org
>Subject: Re: [OT] JPetStore - BaseBean / BeanAction
>Date: Thu, 12 May 2005 19:01:02 -0600
>
>i'm not sure about your "formAction" semantic. You should name it
>something meaningful like "removeFoo". The method names should be
>named after the actions that are taking place.
Yes, I should have given my real problem instead of this one. But that would
mean my action would be called: folderActions. And the methods foo and bar
would be: remove and edit.
>But, yes you would follow the same semantic. You need to realize that
>JPetstore is NOT
>standard struts practice. It is a way to use struts in a more modern
>manner (i.e. Action has properties on it rather than sepearate in an
>ActionForm.).
And I like this modern way better than the old one. :)
>Otherwise, it sounds like you have the idea down fairly well.
>
>Brandon
>
>On 5/12/05, Lieven De Keyzer <li...@hotmail.com> wrote:
> > I took the lastest JPetStore as a starting point for my application.
> >
> > The problem I have now: I want to have multiple actions in one form. I
>have
> > a set of objects belonging to a user and this are displayed together
>with a
> > checkbox for each object. I want the users to be able to check a few
>boxes
> > and let them choose to delete those, or edit them all at once, etc...
> >
> > Normall I think one should implement a class that inherits from the
> > DispatchAction Class.
> >
> > I guess using the BaseBean and BeanAction class, this should even be
> > simpler. Should I use the same tactic as the DispatchAction class uses ?
> > Something like:
> >
> > public Class TreeLevel extends BaseBean {
> >
> > private String method;
> >
> > public String formAction {
> > if (method == "foo") {
> > return foo(); }
> > else { return bar(); }
> > }
> >
> > private String foo() {
> > //
> > }
> >
> > private String bar() {
> > }
> > }
> >
> > And then in my jsp page:
> >
> > <html:form action="/formAction">
> > <html:submit property="method" value="foo" />
> > <html:submit property="method" value="bar" />
> > </html:form>
> >
> >
Re: [OT] JPetStore - BaseBean / BeanAction
Posted by Brandon Goodin <br...@gmail.com>.
i'm not sure about your "formAction" semantic. You should name it
something meaningful like "removeFoo". The method names should be
named after the actions that are taking place. But, yes you would
follow the same semantic. You need to realize that JPetstore is NOT
standard struts practice. It is a way to use struts in a more modern
manner (i.e. Action has properties on it rather than sepearate in an
ActionForm.). Otherwise, it sounds like you have the idea down fairly
well.
Brandon
On 5/12/05, Lieven De Keyzer <li...@hotmail.com> wrote:
> I took the lastest JPetStore as a starting point for my application.
>
> The problem I have now: I want to have multiple actions in one form. I have
> a set of objects belonging to a user and this are displayed together with a
> checkbox for each object. I want the users to be able to check a few boxes
> and let them choose to delete those, or edit them all at once, etc...
>
> Normall I think one should implement a class that inherits from the
> DispatchAction Class.
>
> I guess using the BaseBean and BeanAction class, this should even be
> simpler. Should I use the same tactic as the DispatchAction class uses ?
> Something like:
>
> public Class TreeLevel extends BaseBean {
>
> private String method;
>
> public String formAction {
> if (method == "foo") {
> return foo(); }
> else { return bar(); }
> }
>
> private String foo() {
> //
> }
>
> private String bar() {
> }
> }
>
> And then in my jsp page:
>
> <html:form action="/formAction">
> <html:submit property="method" value="foo" />
> <html:submit property="method" value="bar" />
> </html:form>
>
>