Discussion:
dynamic logic:equal compare possible ?
Marcus Biel
2002-11-26 10:04:17 UTC
Permalink
Hi, I got a table that displays a list of data records.
When editing a data record, I don't want to display the data record to
edit on another page, but on the same page.

Therefore I think I have to use the logic:equal tag to compare the id
value of the current record with the id that got entered into an
"editForm".

So both values to compare are in different forms -

I checked the Docu:
http://localhost:8080/struts-documentation/struts-logic.html#equal
And it says:
value: The constant value to which the variable, specified by other
attribute(s) of this tag, will be compared

So according to the Struts docu, the value must be constant!
But I need to compare a dynamic value!

Any idea how to solve this ?


thx in advance,

marcus
Gemes Tibor
2002-11-26 10:20:10 UTC
Permalink
Post by Marcus Biel
http://localhost:8080/struts-documentation/struts-logic.html#equal
value: The constant value to which the variable, specified by other
attribute(s) of this tag, will be compared
So according to the Struts docu, the value must be constant!
But I need to compare a dynamic value!
<bean:define id="value1" name="oneForm" property="oneProperty" />

<logic:equals
name="otherForm"
property="otherProperty"
value="<%= oneValue %>" >
Gemes Tibor
2002-11-26 10:26:12 UTC
Permalink
Post by Gemes Tibor
<bean:define id="value1" name="oneForm" property="oneProperty" />
Of course this should be:

<bean:define id="oneValue" name="oneForm" property="oneProperty" />

<logic:equal
name="otherForm"
property="otherProperty"
value="<%= oneValue %>" >


sorry. I think I should boot on my first coffee. Ugh.

Tib
Marcus Biel
2002-11-26 13:47:32 UTC
Permalink
Thanks.
Going to try this asap.

marcus
Post by Gemes Tibor
Post by Gemes Tibor
<bean:define id="value1" name="oneForm" property="oneProperty" />
<bean:define id="oneValue" name="oneForm" property="oneProperty" />
<logic:equal
name="otherForm"
property="otherProperty"
value="<%= oneValue %>" >
sorry. I think I should boot on my first coffee. Ugh.
Tib
--
Marcus Biel
2002-11-26 15:16:37 UTC
Permalink
Works perfect,
even though it makes my jsp even harder to handle! :-)

marcus
Post by Gemes Tibor
Post by Gemes Tibor
<bean:define id="value1" name="oneForm" property="oneProperty" />
<bean:define id="oneValue" name="oneForm" property="oneProperty" />
<logic:equal
name="otherForm"
property="otherProperty"
value="<%= oneValue %>" >
sorry. I think I should boot on my first coffee. Ugh.
Tib
--
Marcus Biel
2002-11-26 13:51:36 UTC
Permalink
Somewhere along the way I've read that you can display dynamic localized
messages,
by using adding brakets "{}" to your message and to add a parameter to
this message in your action.

Unfortunately I forgot where I found this.

Can anyone explain to me how to create dynamic localized messages - for
example adding specific error codes ?

thx,

marcus
Quentin.Cope
2002-11-26 13:57:04 UTC
Permalink
Marcus

Localisation is done as per the rest of the app. So for me I have:

ExceedsAvailable=Exceeds available quantity ({0}) in ApplicationResources.properties and

ExceedsAvailable=Quantita` disponibile superata ({0}) in ApplicationResources_it.properties


The dynamic message would be something like:

errors.add("amount",new ActionError("ExceedsAvailable",
new Integer(productinfo.getAvailableToOrder())
));

there's a whole set of add methods to accomodate different numbers of parameters.

Regards

Quentin


-----Original Message-----
From: Marcus Biel [mailto:***@bmw.de]
Sent: 26 November 2002 13:52
To: struts-***@jakarta.apache.org
Subject: dynamic local message / dynamic error codes


Somewhere along the way I've read that you can display dynamic localized
messages,
by using adding brakets "{}" to your message and to add a parameter to
this message in your action.

Unfortunately I forgot where I found this.

Can anyone explain to me how to create dynamic localized messages - for
example adding specific error codes ?

thx,

marcus

--
To unsubscribe, e-mail: <mailto:struts-user-***@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-***@jakarta.apache.org>
Marcus Biel
2002-11-27 07:56:58 UTC
Permalink
Hi there,

I working with Struts 1.02 quite a while now,
and did a very complicated application using Struts,

but the more I know, the more I realize that I don't exactly know the
basics:

What exactly is the difference between the different scopes & which
scopes are there,
besides request, session & page ? When to use whichsoever scope ?

What if I am using one form for different actions, using different
scopes ?
Could it be that that creates different ActionForms in different scopes
of the same type ???


thx in advance,

marcus
Gemes Tibor
2002-11-27 08:20:15 UTC
Permalink
Post by Marcus Biel
What if I am using one form for different actions, using different
scopes ?
Could it be that that creates different ActionForms in different scopes
of the same type ???
Yes.

If you don't want to hide one form from the other you might want to use the
"attribute" attribute of the ActionMapping. I use this in case of 2 session
scope ActionForm of the same type.

Tib
Marcus Biel
2002-12-03 08:37:03 UTC
Permalink
I got a form for editing a data records.
When I hit "cancel" I want to display an other page then when I hit
submit.

How to do this ?


thx,

marcus
Gemes Tibor
2002-12-03 08:47:44 UTC
Permalink
Post by Marcus Biel
I got a form for editing a data records.
When I hit "cancel" I want to display an other page then when I hit
submit.
How to do this ?
Read the docs! Take a look at the struts-example.war, or read the struts-tips
at husted.com:

http://www.husted.com/struts/tips/014.html

Hth,

Tib
Andrew Hill
2002-12-03 08:52:56 UTC
Permalink
One way is to do a forward from within the action. Ie: both buttons still
submit to same action to start with, but if its detected that it was a
cancel then the action immediately returns an ActionForward that forwards
the request on to the action/jsp/etc... that you want to go to if they hit
cancel.

-----Original Message-----
From: Marcus Biel [mailto:***@bmw.de]
Sent: Tuesday, December 03, 2002 16:37
To: struts-***@jakarta.apache.org
Subject: different forwards from form


I got a form for editing a data records.
When I hit "cancel" I want to display an other page then when I hit
submit.

How to do this ?


thx,

marcus

--
To unsubscribe, e-mail:
<mailto:struts-user-***@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-***@jakarta.apache.org>
Marcus Biel
2002-12-03 09:01:20 UTC
Permalink
No, my problem is different!

A simple reset would be easy -
but I want to hit reset when I am editing -
when editing and I hit submit, it calls an action,
that updates the record,
then it forwards to a new jsp, that's says:
"Your record has been edited successfully."

Now if I add a cancel button, it works,
but also forwards to this same page,
instead of to the regular start page.

marcus
Post by Gemes Tibor
Post by Marcus Biel
I got a form for editing a data records.
When I hit "cancel" I want to display an other page then when I hit
submit.
How to do this ?
Read the docs! Take a look at the struts-example.war, or read the struts-tips
http://www.husted.com/struts/tips/014.html
Hth,
Tib
--
Gemes Tibor
2002-12-03 09:10:51 UTC
Permalink
Post by Marcus Biel
No, my problem is different!
No. Your problem is the same.
Post by Marcus Biel
Now if I add a cancel button, it works,
but also forwards to this same page,
instead of to the regular start page.
If you add a cancel button, you can handle the cancel event by checking
isCancelled(request) so you can decide where forward to.
Simplified:

if (isCancelled(request))
return mapping.findForward("cancel");

And define a forward named 'cancel'. If you do so you will be forwarded to
this page.

Tib
Marcus Biel
2002-12-03 09:22:13 UTC
Permalink
I thought (isCancelled(request))

would be a user defined method.
Are you sure I can simple use this method,
and he will know the user hit the cancel button ?

marcus
Post by Gemes Tibor
Post by Marcus Biel
No, my problem is different!
No. Your problem is the same.
Post by Marcus Biel
Now if I add a cancel button, it works,
but also forwards to this same page,
instead of to the regular start page.
If you add a cancel button, you can handle the cancel event by checking
isCancelled(request) so you can decide where forward to.
if (isCancelled(request))
return mapping.findForward("cancel");
And define a forward named 'cancel'. If you do so you will be forwarded to
this page.
Tib
--
Gemes Tibor
2002-12-03 09:48:56 UTC
Permalink
Post by Marcus Biel
I thought (isCancelled(request))
would be a user defined method.
Are you sure I can simple use this method,
and he will know the user hit the cancel button ?
If the cancel button was generated with <html:cancel>cancel</html:cancel>

Hth,

Tib

s***@ubs.com
2002-11-27 09:15:16 UTC
Permalink
Can you please explain how to use this attribute of action mapping?Do u mean
that if same form is defined with two diferent scopes and same name, still u
can reuse same instance,using attribute?

I checked the javadoc for attribuite of ActionMapping class.It does not give
much idea about how to use it.

regards,
Shirish



-----Original Message-----
From: gemes [mailto:***@regens.hu]
Sent: Wednesday, November 27, 2002 9:20 AM
To: struts-user
Cc: gemes
Subject: Re: newbie question from expierenced user
Post by Marcus Biel
What if I am using one form for different actions, using different
scopes ?
Could it be that that creates different ActionForms in different scopes
of the same type ???
Yes.

If you don't want to hide one form from the other you might want to use the
"attribute" attribute of the ActionMapping. I use this in case of 2 session
scope ActionForm of the same type.

Tib

--
To unsubscribe, e-mail: <mailto:struts-user-***@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-***@jakarta.apache.org>
Gemes Tibor
2002-11-27 09:27:08 UTC
Permalink
Post by s***@ubs.com
Can you please explain how to use this attribute of action mapping?Do u
mean that if same form is defined with two diferent scopes and same name,
still u can reuse same instance,using attribute?
If you define it to different scope with the same name, then they will be
found in the following order:

page -> request -> session -> application.

So if you store with the same name in request and session scope, and you don't
supply the bean:define the scope explicitely, only the request scope bean
will be found.

If you intend to use the same formbean with 2 ActionMapping and you don't want
to interfere these actions, then you add for both mappings the same "name"
attribute and different "attribute" attribute. So both action will use the
same type of form but store under different attribute.

Hth,

Tib
A***@itsprojects.com
2002-11-27 09:56:39 UTC
Permalink
Hi All,
We have decided to go ahead with deploying struts framework on Websphere
4.0 so any body u has any idea /resource on it , pls share it with me

Thanks in advance

abhishek

-----------------------Disclaimer------------------------

The views of the author may not necessarily reflect those
of the Company. All liability is excluded to the extent
permitted by law for any claims arising as a result of the
use of this medium to transmit information by or to
IT Solutions (India) Pvt. Ltd.

We have taken precautions to minimize the risk of
transmitting software viruses, but we advise you to
carry out your own virus checks on any attachment to
this message. We cannot accept liability for any loss or
damage caused by software viruses.

------------------------Disclaimer------------------------
s***@ubs.com
2002-11-27 12:14:49 UTC
Permalink
But how do i access Those different forms in The jsps ?because as far as i
know,I use the name attribuite from action mapping of action to get the
Formbean in jsps.And because of this, my understanding was that the forms are
stored using the name as key in thier required scopes.
So in this case, both the form beans will have same name.And if as u said,
attribute is used to store the forms, does it means that in the jsps to access
the formbean, i need to use the attribute value instead of name now?

-----Original Message-----
From: gemes [mailto:***@regens.hu]
Sent: Wednesday, November 27, 2002 10:27 AM
To: struts-user
Cc: gemes
Subject: Re: Re: newbie question from expierenced user
Post by s***@ubs.com
Can you please explain how to use this attribute of action mapping?Do u
mean that if same form is defined with two diferent scopes and same name,
still u can reuse same instance,using attribute?
If you define it to different scope with the same name, then they will be
found in the following order:

page -> request -> session -> application.

So if you store with the same name in request and session scope, and you don't
supply the bean:define the scope explicitely, only the request scope bean
will be found.

If you intend to use the same formbean with 2 ActionMapping and you don't want
to interfere these actions, then you add for both mappings the same "name"
attribute and different "attribute" attribute. So both action will use the
same type of form but store under different attribute.

Hth,

Tib


--
To unsubscribe, e-mail: <mailto:struts-user-***@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-***@jakarta.apache.org>
Gemes Tibor
2002-11-27 12:26:52 UTC
Permalink
Post by s***@ubs.com
But how do i access Those different forms in The jsps ?because as far as i
know,I use the name attribuite from action mapping of action to get the
Formbean in jsps.And because of this, my understanding was that the forms
are stored using the name as key in thier required scopes.
So in this case, both the form beans will have same name.And if as u said,
attribute is used to store the forms, does it means that in the jsps to
access the formbean, i need to use the attribute value instead of name now?
The key under which the ActionForm is stored is the "attribute" attribute of
the ActionMapping which defaults to the "name" attribute if unspecified
afaik.

Btw you usually don't need the key under which the form is stored. But if you
need, then use the "attribute". If it is unspecified use the "name".

Hth,

Tib
micael
2002-11-27 19:30:03 UTC
Permalink
I would strongly suggest you go to the bookstore and read the relevant
parts in Struts in Action. Since you are a professional, you might even
want to buy the book.
Post by Marcus Biel
Hi there,
I working with Struts 1.02 quite a while now,
and did a very complicated application using Struts,
but the more I know, the more I realize that I don't exactly know the
What exactly is the difference between the different scopes & which
scopes are there,
besides request, session & page ? When to use whichsoever scope ?
What if I am using one form for different actions, using different
scopes ?
Could it be that that creates different ActionForms in different scopes
of the same type ???
thx in advance,
marcus
--
Micael

-------------------------------------------------------

This electronic mail transmission and any accompanying documents contain
information belonging to the sender which may be confidential and legally
privileged. This information is intended only for the use of the
individual or entity to whom this electronic mail transmission was sent as
indicated above. If you are not the intended recipient, any disclosure,
copying, distribution, or action taken in reliance on the contents of the
information contained in this transmission is strictly prohibited. If you
have received this transmission in error, please delete the message. Thank you
Marcus Biel
2002-12-03 09:06:10 UTC
Permalink
That's just what I thought would be best.
But how can I see in my Action which button was hit ?
Post by Andrew Hill
One way is to do a forward from within the action. Ie: both buttons still
submit to same action to start with, but if its detected that it was a
cancel then the action immediately returns an ActionForward that forwards
the request on to the action/jsp/etc... that you want to go to if they hit
cancel.
-----Original Message-----
Sent: Tuesday, December 03, 2002 16:37
Subject: different forwards from form
I got a form for editing a data records.
When I hit "cancel" I want to display an other page then when I hit
submit.
How to do this ?
thx,
marcus
--
--
edgar
2002-12-03 09:18:11 UTC
Permalink
Get creative. You can use form data, i.e. a button value is not
submitted unless a button is clicked. You can use javascript to set an
arbitrary set of action variables. You can use a dispatch action.

Have fun with it ;-).

Edgar


-----Original Message-----
From: Marcus Biel [mailto:***@bmw.de]
Sent: Tuesday, December 03, 2002 4:06 AM
To: 'struts-***@jakarta.apache.org'; '***@gridnode.com'
Subject: Re: different forwards from form


That's just what I thought would be best.
But how can I see in my Action which button was hit ?
Post by Andrew Hill
One way is to do a forward from within the action. Ie: both buttons
still submit to same action to start with, but if its detected that it
was a cancel then the action immediately returns an ActionForward that
forwards the request on to the action/jsp/etc... that you want to go
to if they hit cancel.
-----Original Message-----
Sent: Tuesday, December 03, 2002 16:37
Subject: different forwards from form
I got a form for editing a data records.
When I hit "cancel" I want to display an other page then when I hit
submit.
How to do this ?
thx,
marcus
--
--
--
To unsubscribe, e-mail:
<mailto:struts-user-***@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-***@jakarta.apache.org>
Loading...