RE: passing object in request from jsp to action

2005-03-31 Thread Nidel, Mike
Due to the nature of HTTP, you cannot pass an object from
the client's browser to the Action. Instead you either need
to

a. pass the form fields/request parameters you need to build
your object again

or

b. store the Object in the session so you can retrieve it when
the Action is called.


I don't know of any other way...

 -Original Message-
 From: temp temp [mailto:[EMAIL PROTECTED]
 Sent: Thursday, March 31, 2005 2:22 PM
 To: Struts Users Mailing List; Hubert Rabago
 Subject: Re: passing object in request from jsp to action
 
 
 By submitting a form to the action how can I pass some
 object using request.setAttribute  ?could you guide me
 with this.
 thanks  regards
 
 
 --- Hubert Rabago [EMAIL PROTECTED] wrote:
  Once the JSP has been rendered, processing for that
  request is done. 
  Anything placed in request attributes while the JSP
  was processing are
  gone.  To pass data from the generated HTML to an
  action, you need to
  submit a form or include request parameters in a
  link.  Another option
  is to store the object in session scope.
  
  Hubert
  
  
  On Thu, 31 Mar 2005 11:10:36 -0800 (PST), temp temp
  [EMAIL PROTECTED] wrote:
   I want pass an object  from a jsp to an struts
  action
in request attribute.
   
   I have a jsp it got  link to an action upon click
  the
   action is invoked. How can I pass object to this
   action  using request Attribute.
   thanks  regards
   
   __
   Do you Yahoo!?
   Yahoo! Small Business - Try our new resources
  site!
   http://smallbusiness.yahoo.com/resources/
   
  
 
 -
   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]
  
  
 
 
   
 __ 
 Yahoo! Messenger 
 Show us what our next emoticon should look like. Join the fun. 
 http://www.advision.webevents.yahoo.com/emoticontest
 
 -
 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: DynaValidatorForm and Checkbox

2005-03-30 Thread Nidel, Mike
Having never used DynaValidatorForm before, I'm not 100% sure what
the means for accessing the properties would be. It's clear that
getCatalogID() is not going to be defined on DynaValidatorForm
as an available method. So I'd try calling getDynaProperty() and
if that doesn't work you should research further into how DynaForms
operate.

Sorry for the limited reply, but maybe it will help anyway.

Mike

 -Original Message-
 From: Scott Purcell [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, March 30, 2005 11:40 AM
 To: Struts Users Mailing List
 Subject: RE: DynaValidatorForm and Checkbox
 
 
 Ok,
 making headway but have issue:
 
 Since it is a single checkbox, I am using a Boolean, so here 
 is my bean:
 
 form-bean name=covers
   type=org.apache.struts.validator.DynaValidatorForm
   form-property name=covers type=java.lang.Boolean
   form-property name=catalogID type=java.lang.String
 /form-bean
 
 
 Now when the user submits the form, there will be a catalogID set.
 
 So I am trying to pull out the catalogID like this in my Action class:
 public ActionForward executeAction(ActionMapping mapping,
  ActionForm form,
  HttpServletRequest request,
  HttpServletResponse response,
  AppObject appObject,
  UserObject user)
 throws Exception {
 
 
 DynaValidatorForm theForm = (DynaValidatorForm)form;
 
 String catalogID = theForm.getCatalogID();
 Boolean checkbox = theForm.getCovers();
 
 
 
 But it will not compile. How do I get the values from the 
 form? I usually create my own physical bean.
 
 Thanks,
 Scott
 
 
 
 
 -Original Message-
 From: Wendy Smoak [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, March 30, 2005 10:13 AM
 To: Struts Users Mailing List
 Subject: Re: DynaValidatorForm and Checkbox
 
 
 From: Scott Purcell [EMAIL PROTECTED]
  I have a couple of jsp pages where there is a single 
 checkbox on the page.
  But as a newbie, I am not sure what type in the creation to 
 make it? A
 String? A Boolean?
 
 I usually use Boolean for checkboxes.  (Read the docs about using the
 'reset' method to make 'un-checking' the box possible.)
 
 If it's a yes/no question, I sometimes use a pair of radio 
 buttons for Y
 or N.
 
 -- 
 Wendy Smoak
 
 
 -
 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]
 
 

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



RE: bean in a Actionform

2005-03-30 Thread Nidel, Mike
Hello Temp,

It seems like you want to use a combination of the
nested bean property naming and list-backed properties.

I think your property name in the form element will be
something like

mybean.prop


which will result in form.getMybean().setProp() when
the form is submitted.

I believe your setProp() should accept a String[]
(array) rather than just a single String. Each of
the items that is selected will be passed into setProp()
inside this array.

You may need to name your method setProps() (notice
the 's' in the name) -- I'm not totally sure.

Good luck,

Mike


 -Original Message-
 From: temp temp [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, March 30, 2005 12:34 PM
 To: user@struts.apache.org
 Subject: bean in a Actionform
 
 
 I have an actionform which contains  a bean as a
 property. This bean has  getter and setter methods 
 for few Strings . 
 
 1. How to display   properties from this bean  in my
 jsp in a  list . 
 
 And when the form  is submitted 
 
 2. Can I automatically  populate my bean in actionform
  with the values selected from the list when the form
 is submitted ?
 
 thanks  regards
 
 
 
 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam protection around 
 http://mail.yahoo.com 
 
 -
 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: DynaValidationForm Display In JSP?

2005-03-30 Thread Nidel, Mike
Wow. I'm stumped. As I said, I don't have firsthand experience
with DynaForms...

Only thing I can think of is, did you set the input to your
JSP correctly in the struts-config?

Not to sound overly optimistic, but it's GOT to work. It uses
the same functionality on the sending as it does when setting
up the JSP, it's not like it's a separate (difficult) problem
to solve. Maybe double-check your get() method to make sure it
matches your set() as far as return type etc.?

What exactly is the error you get when the JSP blows up?

 -Original Message-
 From: Scott Purcell [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, March 30, 2005 1:04 PM
 To: user@struts.apache.org
 Subject: DynaValidationForm Display In JSP?
 
 
 I have finally figured out how to get my DynaValidationForm 
 data in the Action class using the get() and set(Name, obj);
  
 So I finally got a checkbox set in a DynaValidatorForm 
 object, and I go to my JSP page to display its checked status.
 Since it is a single checkbox, I figured I would throw this 
 into the JSP page, and let it set checked or unchecked 
 depending upon the form value.
  
 But as usual, this tag does cannot fine the 
 getCoversCheckbox() because this is a DynaValidatorForm bean 
 and not a real class file. How does one get this value out 
 ina  JSP page, usign the html: tags?
  
 Anyone 
 I thought the DynaValidatorForm existed to cut down on the 
 number of Physical class beans we had to create. I hope this works. 
  
 JSP page this chokes.
  html:checkbox property=coversCheckbox /
  
  
 config.
 form-bean name=coversBean
   type=org.apache.struts.validator.DynaValidatorForm
   form-property name=coversCheckbox type=java.lang.Boolean /
   form-property name=catalogID type=java.lang.String /
 /form-bean
 
  
 Action
 DynaValidatorForm theForm = (DynaValidatorForm)form;
  
 set checkbox on/off from db query
  if (val)
   theForm.set(coversCheckbox, Boolean.TRUE);
 else
   theForm.set(coversCheckbox, Boolean.FALSE);
  
  
  
  
 Thanks,
 
 Scott K Purcell | Developer | VERTIS | 
 555 Washington Ave. 4th Floor | St. Louis, MO 63101 | 
 314.588.0720 Ext:1320 | [EMAIL PROTECTED] | 
http://www.vertisinc.com http://www.vertisinc.com/  

Vertis is the premier provider of targeted advertising, media, and 
marketing services that drive consumers to marketers more effectively. 
 

 

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



RE: MessageResources in ActionForm

2005-03-28 Thread Nidel, Mike
You might want to check Globals.MESSAGES_KEY

although this isn't how I understood the MessageResources to
work, I thought the ActionMessages was stored in the request
under the Global.MESSAGES_KEY and not the MessageResources...

anybody else?


 -Original Message-
 From: Scott Purcell [mailto:[EMAIL PROTECTED]
 Sent: Monday, March 28, 2005 2:39 PM
 To: user@struts.apache.org
 Subject: MessageResources in ActionForm
 
 
 Hello,
 I am trying to obtain a MessageResources object in a 
 ActionForm and I cannot figure out how.
  
 Prior to the new 1.2.4 struts I used this:
  
 MessageResources resources =
   (MessageResources)req.getAttribute( Action.MESSAGES_KEY );
  
 But it appears depreciated, or non existant in the action class now.
  
 Thanks,
  
 
 Scott K Purcell | Developer | VERTIS | 
 555 Washington Ave. 4th Floor | St. Louis, MO 63101 | 
 314.588.0720 Ext:1320 | [EMAIL PROTECTED] | 
 http://www.vertisinc.com http://www.vertisinc.com/  
 
 Vertis is the premier provider of targeted advertising, media, and 
 marketing services that drive consumers to marketers more 
 effectively. 
  
 
  
 

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



RE: Place message in jsp from action?

2005-03-23 Thread Nidel, Mike
Just having learned this last week, it's fresh in my mind.
Looks like you are missing the call to

this.saveErrors(errors);


this puts the ActionErrors into the request for your JSP
to display.

The other thing I'd say is that ActionErrors is deprecated;
you might use ActionMessages instead, which works EXACTLY
the same way. Then you would use

this.saveMessages(messages);


Good luck,

Mike


PS - not sure you need to get the MessageResources explicitly
 -- maybe that's used by other code further down your class?


 -Original Message-
 From: Scott Purcell [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, March 23, 2005 5:25 PM
 To: user@struts.apache.org
 Subject: Place message in jsp from action?
 
 
 Hello,
  
 After I complete a successful Action, and I forward to my jsp 
 page, I would like to display a status ... something like 
 New User Added.
  
 Something that operates like the ActionErrors object. I tried 
 doing this in my Action class:
 ActionErrors errors = new ActionErrors();
   // Get access to the message resources for this application
   // There's not an easy way to access the resources from 
 an ActionForm
   MessageResources resources =
 (MessageResources)request.getAttribute( Action.MESSAGES_KEY );
   // Check and see if the access number is missing
   ActionError newError = new 
 ActionError(global.error.database.problem);
   errors.add(ActionErrors.GLOBAL_ERROR, newError);
  
 And then tried to pull the error out (just like an form 
 error), but the error never shows? 
 html:errors /
  
 I figured I am missing something, or possibly there is a 
 better way to handle this?
  
 Thanks,
 Scott
  
 
 . 
  
 
  
 

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



RE: Displaying a HashMap as a select

2005-03-08 Thread Nidel, Mike
Note that there's also the java.util.LinkedHashMap which will
maintain whichever order you insert the values in. This gives
you the consistency of TreeMap without the overhead of resorting,
if your data is already sorted when you're populating the Map.
It also has a funky LRU-style option that orders the items based
on which ones have been most recently accessed, but I've never
used that.

I've found LinkedHashMap to be indispensible, and the performance
is good according to the Javadoc.

hth,

Mike


 -Original Message-
 From: Jeff Beal [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, March 08, 2005 9:34 AM
 To: Struts Users Mailing List; [EMAIL PROTECTED]
 Subject: Re: Displaying a HashMap as a select
 
 
 Even if the results coming out of the database are sorted, throwing
 them into a non-sorted Collection, like a basic HashMap, will un-sort
 them.  If you use a List, you just preserve the database sort order. 
 If you use a TreeMap, you can get the same sort order, but the TreeMap
 object will go through the work of sorting them all over again.
 
 
 On Tue, 8 Mar 2005 09:17:49 -0500, David Johnson 
 [EMAIL PROTECTED] wrote:
  my thought was just to let the DB do the work on the 
 sorting. Is that bad?
  
  
  On Mon, 7 Mar 2005 21:29:08 -0700, Wendy Smoak 
 [EMAIL PROTECTED] wrote:
   From: James Mitchell [EMAIL PROTECTED]
I wouldn't use a Map, I would go with a List.  
 Primarily for ordering.
  
   I use java.util.TreeMap-- automatic alphabetical order 
 for my lists of
   (String) codes and descriptions.
  
   --
   Wendy Smoak
  
  
   
 -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
  --
  -Dave
  [EMAIL PROTECTED]
  
  
 -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  
  
 
 
 -- 
 Jeff Beal
 Webmedx, Inc.
 Pittsburgh, PA USA
 
 -
 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: map-backed forms with multibox/multiselect lists?

2005-03-08 Thread Nidel, Mike
The good news is that this DOES work.

I simply declared my methods to be

public void setFoo(String key, String[] foos)
{
...
}

public String[] getFoo(String key)
{
...
}

and everything works fine. It took a detour through the Struts
source (and ultimately from there through the beanutils source)
to figure this out, but the problem was essentially that when
doing the bean introspection, the beanutils first finds the getFoo()
method and stores its return type. It then looks for a setFoo()
method with the same argument type as the return type of getFoo().
If you try to return foo as an Object, it just won't work -- your
setter won't be found and the method will never be called.

thanks for the input,

Mike


 -Original Message-
 From: Radu Badita [mailto:[EMAIL PROTECTED]
 Sent: Monday, March 07, 2005 11:10 AM
 To: Struts Users Mailing List
 Subject: RE: map-backed forms with multibox/multiselect lists?
 
 
 
 I had the same problem some time ago (the solution vaguely 
 suggested by 
 Jack wouldn't had been an option since the properties were 
 dynamic so I 
 needed the key to distinguish between them). I asked on this 
 list for help 
 at that time, but didn't got an answer, so I guess nobody 
 succeeded in 
 doing something like this. Therefore I had to find some other 
 solution to 
 my problem...
 I'm guessing this might be some sort of a problem with 
 commons-binutils 
 (although public void setFoos(String key, String[] foos) 
 isn't a valid 
 javabeans setter so maybe it's just a bit out of it's scope).
 
 At 16:44 07.03.2005, you wrote:
 This works fine for list-backed form items (which we also use)
 but in this case I need something like
 
 public void setFoos(String key, String[] foos)
 
 is this possible?
 
 
 There are several workarounds I can think of, but this appears
 to be the cleanest solution if I can make it work.
 
 Mike
 
   -Original Message-
   From: Dakota Jack [mailto:[EMAIL PROTECTED]
   Sent: Monday, March 07, 2005 9:42 AM
   To: Struts Users Mailing List
   Subject: Re: map-backed forms with multibox/multiselect lists?
  
  
   public void setFoos(String [] foos)
  
  
   On Fri, 4 Mar 2005 18:55:53 + (UTC), Mike Nidel
   [EMAIL PROTECTED] wrote:
I'm trying to build a form element that combines the
   features of a map-backed
property with a multibox (and the same for a
   multiple-selection list). I've made
multiboxes work fine without the map-backed element, but I
   can't seem to get
this to work.
   
I've tried various method signatures in my form bean, but
   to no avail. For
example, for a field called foo I have tried the following:
   
public void setFoo(String key, Object val)
{
...
}
   
or
   
public void setFoo(String key, String[] val)
{
...
}
   
I'm using a set of checkboxes on the JSP which should
   result in a list of the
values of whichever boxes are selected. I can think of a
   number of javascript
workarounds, as well as workarounds in my Action that go
   directly to the request
parameters... but all of those are kludges and it seems
   like there should be a
way to have multiple checkboxes that all reference a
   map-backed form property.
   
Any thoughts?
   
thanks a bunch,
   
Mike Nidel
   
   
   
 -
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
   
   
  
  
   --
   You can lead a horse to water but you cannot make it float
   on its back.
   ~Dakota Jack~
  
   
 -
   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]
 
 
 
 -
 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: struts html tags and form-beans

2005-03-08 Thread Nidel, Mike
No. This won't work automatically.

You can, however, use the bean:write... tags or use scriptlet
code to access your form bean in the request/session and
pull the properties out that you need.


 -Original Message-
 From: wo_shi_ni_ba_ba [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, March 08, 2005 3:28 PM
 To: Struts Users Mailing List; Jeff Beal
 Subject: Re: struts html tags and form-beans
 
 
 hi,
 What I meant was even if I don't use strut's html tags
 I would still be able to take advantage of this
 automation, right?(or not?)  I want to use plain html
 to render input types.
 
 
 --- Jeff Beal [EMAIL PROTECTED] wrote:
  Yes.  The html:/ tags automate the work of pulling
  values from the
  form and displaying them to the user.  For example,
  in the case of
  displaying invalid responses to the user for them to
  correct.
  
  
  On Tue, 8 Mar 2005 11:07:15 -0800 (PST),
  wo_shi_ni_ba_ba
  [EMAIL PROTECTED] wrote:
   hi folks,
   if I just use plain html code(not struts html:
  tags)
   for  constructing input types like radios,
   textfield,etc, would I still be able to use
  form-bean
   for automatic retrieving and populating as long as
  I
   wrap all the inputs in a form and set the form
  action
   to be an action associated with a form-bean in
   struts-config?
   thanks
   
   __
   Celebrate Yahoo!'s 10th Birthday!
   Yahoo! Netrospective: 100 Moments of the Web
   http://birthday.yahoo.com/netrospective/
   
  
 
 -
   To unsubscribe, e-mail:
  [EMAIL PROTECTED]
   For additional commands, e-mail:
  [EMAIL PROTECTED]
   
   
  
  
  -- 
  Jeff Beal
  Webmedx, Inc.
  Pittsburgh, PA USA
  
 
 -
  To unsubscribe, e-mail:
  [EMAIL PROTECTED]
  For additional commands, e-mail:
  [EMAIL PROTECTED]
  
  
 
 
   
   
 __ 
 Celebrate Yahoo!'s 10th Birthday! 
 Yahoo! Netrospective: 100 Moments of the Web 
 http://birthday.yahoo.com/netrospective/
 
 -
 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: map-backed forms with multibox/multiselect lists?

2005-03-07 Thread Nidel, Mike
This works fine for list-backed form items (which we also use)
but in this case I need something like

public void setFoos(String key, String[] foos)

is this possible?


There are several workarounds I can think of, but this appears
to be the cleanest solution if I can make it work.

Mike

 -Original Message-
 From: Dakota Jack [mailto:[EMAIL PROTECTED]
 Sent: Monday, March 07, 2005 9:42 AM
 To: Struts Users Mailing List
 Subject: Re: map-backed forms with multibox/multiselect lists?
 
 
 public void setFoos(String [] foos)
 
 
 On Fri, 4 Mar 2005 18:55:53 + (UTC), Mike Nidel 
 [EMAIL PROTECTED] wrote:
  I'm trying to build a form element that combines the 
 features of a map-backed
  property with a multibox (and the same for a 
 multiple-selection list). I've made
  multiboxes work fine without the map-backed element, but I 
 can't seem to get
  this to work.
  
  I've tried various method signatures in my form bean, but 
 to no avail. For
  example, for a field called foo I have tried the following:
  
  public void setFoo(String key, Object val)
  {
  ...
  }
  
  or
  
  public void setFoo(String key, String[] val)
  {
  ...
  }
  
  I'm using a set of checkboxes on the JSP which should 
 result in a list of the
  values of whichever boxes are selected. I can think of a 
 number of javascript
  workarounds, as well as workarounds in my Action that go 
 directly to the request
  parameters... but all of those are kludges and it seems 
 like there should be a
  way to have multiple checkboxes that all reference a 
 map-backed form property.
  
  Any thoughts?
  
  thanks a bunch,
  
  Mike Nidel
  
  
 -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  
  
 
 
 -- 
 You can lead a horse to water but you cannot make it float 
 on its back.
 ~Dakota Jack~
 
 -
 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]