Problem with setting up a form and scope

2001-12-05 Thread Scriven, Marcos

I have a product form, which I load in the following way:

1) request setupProductForm.do?isin=AB123456789X&action=0
2) This then runs the setup product action - it loads the product according
to the given ISIN, and sets the action
3) At the end of the action, I put in the following code:

if ("request".equals(mapping.getScope())) {
request.setAttribute(mapping.getAttribute(), productForm);
}
else {
HttpSession session = request.getSession();
session.setAttribute(mapping.getAttribute(), productForm);
}

I took this from the example app

4) This forwards on to productForm.jsp

Unfortunately, I keep getting the following exception:

javax.servlet.jsp.JspException: No bean found under attribute key
productForm
at
org.apache.struts.taglib.logic.CompareTagBase.condition(CompareTagBase.java:
222)

The only way I've been able to get rid of this is by changing the scope to
session - however, I really don't need it on the session, and don't really
want to be responsible for cleaning it up after use.

The salient parts of my strut-config are:

  




  

  
   


  




  

  

Any ideas what I'm doing wrong? Also, is there a simpler/cleaner way of
setting up a form?

Thanks

Marcos

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Setting up form from the query string

2001-12-04 Thread Scriven, Marcos

Hi

Is it possible in struts to setup a form like so:

myForm.jsp?action=3

Where in the form you have a property called action? The only way I have
been able to do it is this:


"/>

Which seems to be a bit redundant, what with repeating the property name.
I've also tried the method given in the examples app, whereby I have an
action just to set up the form. This seems rather an overkill for a form I
simply want to populate with a copule of values. Even then I still have to
pass the values in the URL like so: setupMyForm?action=3, which then
forwards to the new form bean, which then reads the values out of the
populated bean.

There must be an easier way!

Thanks

Marcos

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Setting up a form in an action

2001-11-19 Thread Scriven, Marcos

Hi Tom

Thanks for that

Where is a good place to remove beans from the session scope? Do I have to
forward to an action that does this for me?

Also, I thought there was a difference between 'page' and 'request' scope.
Is there no such thing as page scope in struts?

Marcos

> -Original Message-
> From: Tom Klaasen (TeleRelay) [mailto:[EMAIL PROTECTED]]
> Sent: 19 November 2001 09:16
> To: Struts Users Mailing List
> Subject: RE: Setting up a form in an action
> 
> 
> 
> 
> > -Original Message-
> > From: Scriven, Marcos [mailto:[EMAIL PROTECTED]] 
> > Sent: zondag 18 november 2001 18:32
> > To: 'Struts Users Mailing List'
> > Subject: Setting up a form in an action
> > 
> > 
> > I am trying to do this sequence of events:
> > 
> > 1) setupProductForm.do?isin=abcd
> > 
> > 2) This creates a productForm instance, and initialises the 
> > product, based
> > on the given ISIN
> > 
> > 3) persistProduct - This should save the product
> > 
> > What happens at the moment is my form is my setupProductForm action
> > correctly loads the product, and sets it on the form:
> > 
> > productForm.setTradeProduct(tradeProduct);
> > 
> > On success, I forward to 'success', which maps to productForm.jsp
> > 
> >  
> > The action in productForm is persistProduct
> > 
> > When I submit this form, in the validate() method I output 
> > the tradeProduct
> > to the console - this confirms that a new form has been 
> > created, and the
> > attributes persisted from the values in the form.
> > 
> > This wouldn't be a problem, but I have a productID, which is 
> > not in the
> > form, and I don't think it should be. For that reason, it's 
> > just the default
> > '-1' I set it to in the static intialiser.
> > 
> > Do I have to have unseen attributes as hidden fields in the 
> > JSP, and why? 
> 
> Since you're using the 'request' scope, the unseen attributes 
> have to be
> hidden fields, yes. After the first request is sent, Struts 'forgets'
> the form, until it receives it again.
> 
> If you really hate the hidden fields, use the 'application' 
> scope. Don't
> forget to remove the form bean though.
> 
> hth,
> tomK
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

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




Setting up a form in an action

2001-11-18 Thread Scriven, Marcos

I am trying to do this sequence of events:

1) setupProductForm.do?isin=abcd

2) This creates a productForm instance, and initialises the product, based
on the given ISIN

3) persistProduct - This should save the product

What happens at the moment is my form is my setupProductForm action
correctly loads the product, and sets it on the form:

productForm.setTradeProduct(tradeProduct);

On success, I forward to 'success', which maps to productForm.jsp

 
The action in productForm is persistProduct

When I submit this form, in the validate() method I output the tradeProduct
to the console - this confirms that a new form has been created, and the
attributes persisted from the values in the form.

This wouldn't be a problem, but I have a productID, which is not in the
form, and I don't think it should be. For that reason, it's just the default
'-1' I set it to in the static intialiser.

Do I have to have unseen attributes as hidden fields in the JSP, and why? 

My struts-config entry for these two actions is:



  




  
 

Any ideas why this is happening, or how I should get around it?

Thanks

Marcos

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




reusing form for readonly

2001-11-18 Thread Scriven, Marcos

Hi

I have a form which can be in several different modes: VIEW, ADD, EDIT, and
DELETE

If I am in view mode (which I have enumerated as 0 in an interface called
WebConstants.VIEW), I want the values in my  fields to be
readonly.

I can do this on a field by field basis, as such:








However, is there a shorter/more succinct way? I have many fields within my
form, and adding all these equal/notEqual tags adds a lot of lines to my JSP


Thanks

Marcos

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Please help - I'm not getting anywhere with this

2001-11-16 Thread Scriven, Marcos

Thanks Ken

It's just the first part I don't understand. How do I fire off an Action,
before going to the form for the first time? Also, how do I tell the Action
which form to use?

Thanks

Marcos

> -Original Message-
> From: Fletcher, Ken [mailto:[EMAIL PROTECTED]]
> Sent: 16 November 2001 15:22
> To: 'Struts Users Mailing List'
> Subject: RE: Please help - I'm not getting anywhere with this
> 
> 
> Create an action class that sets the form bean's field, then 
> add the form
> bean to the request before you forward to that page.  You'll 
> also need to
> use the appropriate tag in your jsp:  
> 
> ...and, of course, have your form defined in your 
> struts-config.xml, etc.,
> etc
> 
> -Original Message-
> From: Scriven, Marcos [mailto:[EMAIL PROTECTED]]
> Sent: Friday, November 16, 2001 8:53 AM
> To: 'Struts Users Mailing List'
> Subject: Please help - I'm not getting anywhere with this
> 
> 
> Any ideas?
> 
> > -Original Message-
> > From: Scriven, Marcos 
> > Sent: 16 November 2001 11:00
> > To: 'Struts Users Mailing List'
> > Subject: Struts JSP not reading parameters from URL
> > 
> > 
> > Hi
> > 
> > I've got a JSP which when rendered contains the line:
> > 
> >  > maxlength="17" size="17"
> > value="" onblur="javascript:validateName(this);" class="form2">
> > 
> > Now, if I open this page with the URL 
> > mypage.jsp?tradeProduct.ISIN=abcd
> > 
> > The ISIN field is not set - I fear it's being ignored, and 
> > then set from the
> > form bean.
> > 
> > How, therefore, do I set the form field to a value when it is 
> > first loaded?
> > Basically, I want to load this page with the ISIN number of 
> > the product I
> > wish to edit.
> > 
> > Thanks
> > 
> > Marcos
> > 
> > --
> > To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

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




Please help - I'm not getting anywhere with this

2001-11-16 Thread Scriven, Marcos

Any ideas?

> -Original Message-
> From: Scriven, Marcos 
> Sent: 16 November 2001 11:00
> To: 'Struts Users Mailing List'
> Subject: Struts JSP not reading parameters from URL
> 
> 
> Hi
> 
> I've got a JSP which when rendered contains the line:
> 
>  maxlength="17" size="17"
> value="" onblur="javascript:validateName(this);" class="form2">
> 
> Now, if I open this page with the URL 
> mypage.jsp?tradeProduct.ISIN=abcd
> 
> The ISIN field is not set - I fear it's being ignored, and 
> then set from the
> form bean.
> 
> How, therefore, do I set the form field to a value when it is 
> first loaded?
> Basically, I want to load this page with the ISIN number of 
> the product I
> wish to edit.
> 
> Thanks
> 
> Marcos
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

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




Struts JSP not reading parameters from URL

2001-11-16 Thread Scriven, Marcos

Hi

I've got a JSP which when rendered contains the line:



Now, if I open this page with the URL mypage.jsp?tradeProduct.ISIN=abcd

The ISIN field is not set - I fear it's being ignored, and then set from the
form bean.

How, therefore, do I set the form field to a value when it is first loaded?
Basically, I want to load this page with the ISIN number of the product I
wish to edit.

Thanks

Marcos

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: AW: how do I use

2001-11-12 Thread Scriven, Marcos
Use icon"; break;
> }
> return text;
> }
> 
> public static Collection getMyOptionss() {
> Collection list = (Collection) new ArrayList();
> for (int i=-5; i<2; i++) {
>   list.add(new LabelValueBean(
>   getMyOptions(i),
>   String.valueOf(i)
>   ));
> }
> return list;
> }
> 
> Then in the ActionForm, a wrapper method can be used:
> 
> 
> public Collection getMyOptions() {
> return app.StaticClass.getMyOptions();
> }
> 
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel +1 716 737-3463
> -- http://www.husted.com/struts/
> 
> 
> > -Ursprüngliche Nachricht-
> > Von: Scriven, Marcos [mailto:[EMAIL PROTECTED]]
> > Gesendet: Donnerstag, 8. November 2001 21:23
> > An: 'Struts Users Mailing List'
> > Betreff: how do I use 
> >
> > I've just done a search on google for "option tag struts", 
> and bizzarely the
> > only thing I get back is about pro-wrestling?!
> >
> > I am stumped by the struts documentation on the 
>  tag, for the
> > collection property...
> >
> > "Name of the JSP bean (in some scope) which is itself a 
> Collection of other
> > beans, each of which has properties named by the "property" and
> > "labelProperty" attributes that are used to retrieve the 
> value and label for
> > each option, respectively. [RT Expr] "
> >
> > Say I have a bean class called Currency, with methods getValue() and
> > getName().
> >
> > In the options tag, I would have the following properties:
> >
> > property="value"
> > labelProperty="name"
> >
> > but what should collection be? It says it should be a 'a bean which
> > represents a collection'...
> >
> > I have set up a collection of beans like so in my form bean 
> (just for
> > testing, can easily go elsewhere)
> >
> > Collection currencies = new Vector();
> > currencies.add(new Currency(0, "USD"));
> > currencies.add(new Currency(1, "GBP"));
> > currencies.add(new Currency(2, "EUR"));
> > ...
> > etc
> >
> > I've then tried putting in an accesor on my bean called 
> getCurrencies()
> >
> > I'm very confused, please help
> >
> > Marcos
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>






--

This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.



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

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




RE: Struts Vs Expresso 4

2001-10-31 Thread Scriven, Marcos

What is 'webappwriter' - sounds like my kinda software!

Any ideas where I can find out more about it, and when it might be released?

There's a lot off 'guff' when writing a web app that I really want to avoid
- I just want to design the business logic and the view, and leave most of
the rest of it to some framework

Marcos

> -Original Message-
> From: Pete Carapetyan [mailto:[EMAIL PROTECTED]]
> Sent: 31 October 2001 13:26
> To: Struts Users Mailing List
> Subject: Re: Struts Vs Expresso 4
> 
> 
> >  Since Expresso v4 is incorporating Struts into its 
> framework, does it
> > nesssarily mean that it is better?
> 
> No, because ~better~ is a meaningless word. Some people like 
> to use vi or
> notepad, others prefer an IDE. Either one get's the job done.
> 
> Expresso is a relatively heavyweight framework, incorporating 
> tons of features
> such as automated table manipulation, caching, logging, xml 
> automation, testing,
> registration objects, on and on.
> 
> As such, it is perfect for guys like me, who just want to get 
> the work done, but
> a challenge for someone who feels cramped using interfaces 
> not invented on his
> own box, or wishes to use raw J2EE without all the help from 
> the 300 or so
> classes that Expresso provides.
> 
> Using webAppWriter, I can get an app written and deployed in 
> an hour, as opposed
> to the month or so it took me when I was using straight J2EE. 
> This Struts
> version, however, is still not public.
> 
> Even though most of Expresso is optional, there does not 
> appear to be a large
> percentage of developers who use it in that manner.
> 
> Expresso uses mostly Apache modules such as log4j, but the 
> data access objects
> are it's own, and there you will find the biggest time 
> savings for your
> development schedule.
> 
> > Expresso has a framework for EJB right?
> 
> No, but as soon as we get some more contributors active in 
> that area, it should
> be forthcoming. All the pieces are in place...:)
> --
> Pete Carapetyan
> http://datafundamentals.com
> Java Development Services
> 
> Open standards technology for commercial profitability
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> 
> For additional commands, e-mail: 
> 
> 

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: problem with tag

2001-10-23 Thread Scriven, Marcos

Hi Rob

Here is my validate method (from the ActionForm bean):

public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request) {
log.debug("Validating form");
ActionErrors errors = new ActionErrors();
if ((_firstName == null) || (_firstName.length() < 1)) {
errors.add("firstName", new
ActionError("error.firstname.required"));
}
if ((_lastName == null) || (_lastName.length() < 1)) {
errors.add("lastName", new
ActionError("error.lastname.required"));
}

return errors;
}

The problem occurs regardless of whether or not I restart the web server.
Here is my entire JSP:

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>







Add Sales Person











  

First Name






  

  

  Last Name


  
  

  

  

  


  

  







Any help gratefully received!

Marcos

> -Original Message-
> From: Rob Breeds [mailto:[EMAIL PROTECTED]]
> Sent: 23 October 2001 12:46
> To: [EMAIL PROTECTED]
> Subject: RE: problem with  tag
> 
> 
> you still get error messages even without the  
> tag? Sounds
> like a restart web app required?
> 
> in the ActionForm validation() method, how do you populate Errors?
> 
> Rob
> 
> 
> 
> 
> 
>   
>   
>       
> "Scriven, 
>   
>   
> Marcos"  To: 
> "'[EMAIL PROTECTED]'" 
> <[EMAIL PROTECTED]>  
>
>   
> [EMAIL PROTECTED]>Subject: RE: 
> problem with  tag
>   
>   
>   
>   
> 23/10/2001
>   
>   
> 12:18 
>   
>   
> Please respond
>   
>   
> to struts-user
>   
>   
>   
>   
>   
>   
>   
>   
> 
> 
> 
> 
> Thanks - but that's exactly what I did!
> 
> I have two text boxes, firstName and lastName
> 
> I triple checked the property names and capitalisation, and I 
> still get all
> the errors.
> 
> Also, I would have thought that not including any error tag 
> would mean no
> errors would be displayed.
> 
> Marcos
> 
> > -Original Message-
> > From: Rob Breeds [mailto:[EMAIL PROTECTED]]
> > Sent: 23 October 2001 12:07
> > To: [EMAIL PROTECTED]
> > Subject: Re: problem with  tag
> >
> >
> > 1. You need to put the 
> > where you want
> > them to appear. If you have several input fields, put a  > property="whatever"/> next to each input field.
> >
> > The header and footer are for formatting but they are optional.
> >
> > Rob Breeds
> >
> >
> >
> >
> >
> >
> >
> >
> > "Scriven,
> >
> >
> > Marcos"  To:
> > "'[EMAIL PROTECTED]'"
> > <[EMAIL PROTECTED]>
> >  >
> >
> > [EMAIL PROTECTED]>Subject: problem
> > with  tag
> >
> >
> >
> >
> > 23/10/2001
> &g

RE: problem with tag

2001-10-23 Thread Scriven, Marcos

Thanks - but that's exactly what I did!

I have two text boxes, firstName and lastName

I triple checked the property names and capitalisation, and I still get all
the errors.

Also, I would have thought that not including any error tag would mean no
errors would be displayed.

Marcos

> -Original Message-
> From: Rob Breeds [mailto:[EMAIL PROTECTED]]
> Sent: 23 October 2001 12:07
> To: [EMAIL PROTECTED]
> Subject: Re: problem with  tag
> 
> 
> 1. You need to put the  
> where you want
> them to appear. If you have several input fields, put a  property="whatever"/> next to each input field.
> 
> The header and footer are for formatting but they are optional.
> 
> Rob Breeds
> 
> 
> 
> 
> 
>   
>       
>   
> "Scriven, 
>   
>   
> Marcos"  To: 
> "'[EMAIL PROTECTED]'" 
> <[EMAIL PROTECTED]>  
>
>   
> [EMAIL PROTECTED]>Subject: problem 
> with  tag
>   
>   
>   
>   
> 23/10/2001
>   
>   
> 11:48 
>   
>   
> Please respond
>   
>   
> to struts-user
>   
>   
>   
>   
>   
>   
>   
>   
> 
> 
> 
> 
> When I get errors with my form validation, I cannot seem to place them
> where
> I want them.
> 
> I have tried  and 
> 
> 1) In both cases (and even when there is no errors tag at 
> all), I get all
> of
> the errors at the top of my page... any ideas why?
> 
> 2) Once I get errors, I then have a page with no javascript on it - in
> which
> case the user can then just type garbage, which I want to check on the
> client side. How do I get around this one?
> 
> I've seen posts that use the errors.header/footer to include 
> some clever
> javascript - is this the only way?
> 
> Thanks
> 
> Marcos
> 
> 
> 



problem with tag

2001-10-23 Thread Scriven, Marcos

When I get errors with my form validation, I cannot seem to place them where
I want them.

I have tried  and 

1) In both cases (and even when there is no errors tag at all), I get all of
the errors at the top of my page... any ideas why?

2) Once I get errors, I then have a page with no javascript on it - in which
case the user can then just type garbage, which I want to check on the
client side. How do I get around this one?

I've seen posts that use the errors.header/footer to include some clever
javascript - is this the only way?

Thanks

Marcos