[Struts 2.1.8] Has struts a problem with using own converts on nested beans?

2010-02-10 Thread Michael Obster

Hi,

does Struts2 has a problem using own converters on nested beans? I 
created a file with -conversion.properties with following 
content:

order.orderPart.property=de.eposcat.xyz.converter.MyOwnConverter

When the action is running the converter is not called (sysout for 
testing on both convert methods, but does not come to the console).


Some testing has shown that
order.property=de.eposcat.xyz.converter.MyOwnConverter
is working.

Can you explain this behaviour, because this from my point of view very 
annoying :-(.


Kind regards,
Michael Obster

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



(SOLVED) Indexed nested beans

2008-04-21 Thread Scott Van Wart

I was missing the getPackages() method :(

- Scott

Scott Van Wart wrote:

Hi all,

I'm trying to get multiple levels of indexed, nested beans working.  
I've tried a variety of solutions but I keep getting xwork or ognl 
exceptions.  Here's what I've tried (loosely):


   public class MyAction implements Action, StrutsStatics {
 private List packages;
 public List getPackages() { return this.packages; }
 public List setPackages( List packages 
) { this.packages = packages; }

   }

   public class PackageBean {
 private List elements;
 public List getElements() { return this.packages; }
 public List setElements( List packages 
) { this.elements = elements; }

   }

   public class ElementBean {
 private String property1;
 private String property2;
 // getters and setters
   }

I refer to the properties in my inputs as 
"packages[0].elements[0].property1".  When I POST, I get a 
NullPointerException in OgnlRuntime.getField (targetClass is null).


I tried using built-in arrays (PackageBean[] and ElementBean[]) and I 
get an OgnlException (source is null in setProperty( null, "property1" 
)).  I try initializing these to new PackageBean[0] and new 
ElementBean[0] and I get IndexOutOfBoundsException.


I tried pre-populating my collections (List<...>) with a few empty 
beans in both my action and PackageBean but I get the "source is null" 
exception again... I also tried the getPackage( int index ) and 
setPackage( int index, PackageBean pkg ) style getters and setters all 
the way through (initializing the lists with empty beans as necessary) 
with no success.


Am I way off on my thoughts of how nested beans and indexed properties 
work?


Thanks,
 Scott


-
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]



Indexed nested beans

2008-04-21 Thread Scott Van Wart

Hi all,

I'm trying to get multiple levels of indexed, nested beans working.  
I've tried a variety of solutions but I keep getting xwork or ognl 
exceptions.  Here's what I've tried (loosely):


   public class MyAction implements Action, StrutsStatics {
 private List packages;
 public List getPackages() { return this.packages; }
 public List setPackages( List packages ) 
{ this.packages = packages; }

   }

   public class PackageBean {
 private List elements;
 public List getElements() { return this.packages; }
 public List setElements( List packages ) 
{ this.elements = elements; }

   }

   public class ElementBean {
 private String property1;
 private String property2;
 // getters and setters
   }

I refer to the properties in my inputs as 
"packages[0].elements[0].property1".  When I POST, I get a 
NullPointerException in OgnlRuntime.getField (targetClass is null).


I tried using built-in arrays (PackageBean[] and ElementBean[]) and I 
get an OgnlException (source is null in setProperty( null, "property1" 
)).  I try initializing these to new PackageBean[0] and new 
ElementBean[0] and I get IndexOutOfBoundsException.


I tried pre-populating my collections (List<...>) with a few empty beans 
in both my action and PackageBean but I get the "source is null" 
exception again... I also tried the getPackage( int index ) and 
setPackage( int index, PackageBean pkg ) style getters and setters all 
the way through (initializing the lists with empty beans as necessary) 
with no success.


Am I way off on my thoughts of how nested beans and indexed properties work?

Thanks,
 Scott


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



Re: [S2] Data entry form for nested beans

2007-04-23 Thread Mark Menard
On 4/23/07 1:03 PM, "Skip Hollowell" <[EMAIL PROTECTED]> wrote:

> I have the following Bean, which represents an Account I am working on:
> 
> public class PaymentBean {
>   String acctNumber;
>   DebtorBean debtor;
>   PayorBean   payor;
>   CreditCardBean cc;
>   SinglePaymentBean[] singlePayment;
> }
> 
> I have tried several different ways in my AccountAction to populate this
> bean from the data entered on the form.   I can, of course, read
> multiple layers down inside my nested beans and display it in a JSP, but
> how I do I allow for data entry into them?

Yes, reading is more intuitive than writing into the data model.

I don't know how others do this, but this is what I do.

You have the PaymentBean which has dependencies. So, in my action's
prepare() method I would instantiate those beans and wire them together.

Public class MyAction extends ActionSupport implements Preparable {

  private PaymentBean paymentBean;

  public void prepare () {
this.paymentBean = new PaymentBean ();
paymentBean.setDebtor (new DebtorBean () );

// Continue this pattern of instantiating and wiring.
  }

  ...

  public PaymentBean getPaymentBean() {
return this.paymentBean;
  }

  ...

}

There might be a way of doing this using the type conversion support, but
I'm personally not familiar with it. (I use factory methods to produce my
various prototype entities, so my controller layer is not tied to a
particular domain model implementation.)

To fill in the DebtorBean.firstName property, if there was one, would be
like this in the JSP:



That will OGNL expression will get the paymentBean from your action, call
getDebtor() on the paymentBean, then call setFirstName() on the DebtorBean.


> Does one create a simple form that has a bunch of simple text fields,
> and the action then uses all of these to populate the pieces of the
> various beans that make up Payment Bean.

You could but it is cumbersome and error prone in my opinion.

Mark
-- 
Mark Menard
Business: http://www.vitarara.net/
Personal: http://www.vitarara.org/
Mark's Struts 2 Cookbook: http://www.vitarara.org/cms/struts_2_cookbook

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



[S2] Data entry form for nested beans

2007-04-23 Thread Skip Hollowell

I have the following Bean, which represents an Account I am working on:

public class PaymentBean {
   String acctNumber;
   DebtorBean debtor;  // The person who owes money(s).  MAkes sense to 
use this bean as I used it throughout the app
   PayorBean   payor;   // The person making the payment(s)  Same 
reason as above.

   CreditCardBean cc;  // The card used to make the payment(s).
   SinglePaymentBean[] singlePayment;   // A bunch of singlePayments to 
be made, with a $ amount, a fee,  and a date

}

I have tried several different ways in my AccountAction to populate this 
bean from the data entered on the form.   I can, of course, read 
multiple layers down inside my nested beans and display it in a JSP, but 
how I do I allow for data entry into them? 

Does one create a simple form that has a bunch of simple text fields, 
and the action then uses all of these to populate the pieces of the 
various beans that make up Payment Bean.  Or is there a correct way to 
represent this structure inside of my form so that the data goes 
directly into the appropriate subBean upon form submittal?  I went 
through the person showcase, and thought I was on the right track, but 
based upon that simple example, i was never able to get the data from 
the form to the bean.  Yes, I can get errors to you from the experiment 
if it helps.


I could supply jsp and action code examples, but they are all just 
failed tests at this point. I am so in need of direction on how best to 
design and implement this base concept in Struts 2.  Any, ANY, advice 
and help would be greatly appreciated.


Skip Hollowell


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



Problems with nested beans and displaying information in a dropdown box

2005-09-29 Thread Justin Galzic
I have a form that contains a bean with a nested collection that I'd like to
prepopulate but I'm having trouble displaying the correct information.. The
output html wiould ideally look like this:

Jon Doe
Jeff Newworth
Amy Madigan


The ActionForm contains the bean with nested beans and the error mesage I
get from Tomcat is "Cannot find bean under name customer".

My form and bean classes are defined as:

public CustomerFormBean extends ActionForm
{
   CustomerBase getCustomerBase() { return customerBase; }
   private CustomerBase customerBase;
}

public class CustomerBase
{
   public Object[] getCustomers() { return customers.toArray(); }
   private ArrayList customers;
}

public class Customer
{
   public String getName() { return name; }
   public String getId() { return id; }

}


My jsp code looks like this:

   










Could some one point me toward the right direction in helping me understand
what's wrong here?

Thanks,
Justin


Re: validate nested beans part 2

2005-07-19 Thread Dave Newton

Scott Purcell wrote:


I dug myself into a corner last night and cannot assemble a viable solution.

I created a bean (usercheckout) which holds two nested beans (Shipping), and (Billing). 
Basically I have the user fill out a shipping form, then they fill out a Billing form. 
The problem is, when I am trying to validate the data, since both are called 
"usercheckout" I can either validate one but not the other. In my 
validation.xml I have this:

   
 
   

And that validates all the nested Billing bean properties. But now when I go to the 
shipping page, I do not know where to validate those because its name is 
"usercheckout".

If I add another field to the above form, then it appears to be looking for two 
names, etc.

Does this make sense?

If anyone has ideas, please let me know,
 

As Michael says, you'll want to use the action mappings as the keys in 
the validation file. Using Dyna beans I use DynaValidatorActionForm 
rather than DynaValidatorForm, so in my validation config file I can use 
the same beans in different actions with different validation rules.


A quick scan of the JavaDocs reveals that if you are hand-coding your 
beans there is a similar hierarchy on the non-dynamic side of things.


Dave



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



Re: validate nested beans part 2

2005-07-19 Thread Michael Jouravlev
On 7/19/05, Scott Purcell <[EMAIL PROTECTED]> wrote:
> I dug myself into a corner last night and cannot assemble a viable solution.
> 
> I created a bean (usercheckout) which holds two nested beans (Shipping), and 
> (Billing). Basically I have the user fill out a shipping form, then they fill 
> out a Billing form. The problem is, when I am trying to validate the data, 
> since both are called "usercheckout" I can either validate one but not the 
> other.

I don't remember the syntax since I do not use validator, but you can
use mapping name instead of form name to distinguish between validated
objects.

Michael.

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



validate nested beans part 2

2005-07-19 Thread Scott Purcell
I dug myself into a corner last night and cannot assemble a viable solution.

I created a bean (usercheckout) which holds two nested beans (Shipping), and 
(Billing). Basically I have the user fill out a shipping form, then they fill 
out a Billing form. The problem is, when I am trying to validate the data, 
since both are called "usercheckout" I can either validate one but not the 
other. In my validation.xml I have this:


  


And that validates all the nested Billing bean properties. But now when I go to 
the shipping page, I do not know where to validate those because its name is 
"usercheckout".

If I add another field to the above form, then it appears to be looking for two 
names, etc.

Does this make sense?

If anyone has ideas, please let me know,

Thanks,
Scott








   

  
  

   

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



Nested Beans and Validation

2005-07-09 Thread Scott Purcell
Hello,

I have been using struts for a bit now, and I am trying to see if the following 
situation is possible.

In a merchant checkout situation, I would like to be able to create a bean that 
has nested beans inside. Eg: This will be a shopping cart checkout, and I have 
the need for an overall bean to keep track of which section they are on, as 
well as creating "Billing" and "Shipping" beans nested inside this bean.

I know from a programmatic side that this is possible, but the problem begins 
with validation and form presentation. Each page currently has a bean 
associated with the action, and on the receiving page I use the html:text, etc. 
tags, and I always have to make sure the proprties are in the bean. But when 
dealing with a bean with a nested bean I do not know how to call the 
html:element?


And if I have one bean associated with many actions, and I have different 
validator.DynaValidatorForm objects, how do I validate nested beans?

In a overall scenario, I would like to be able to create one large bean 
associated with many actions and have the ability to use the html:elements and 
do validation all within the one large bean, validating and using nested bean 
elements?

I have googled around, but do not see anyways to accomplish this short of a 
wizard approach, which I am trying to avoid.

Thanks,
Scott
 




Re: Nested Beans

2005-05-20 Thread Hubert Rabago
Works for me.  If you want, I can send you code later in the day. 
(Will be busy for most of the afternoon).  Or, you can post more of
your code and maybe someone else will spot something.

Hubert

On 5/20/05, Brandon Mercer <[EMAIL PROTECTED]> wrote:
> Hubert Rabago wrote:
> 
> >You might find the nested tags interesting:
> >
> ><%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
> >
> >
> >
> >
> >
> >
> > 
> > 
> >
> >
> >
> >
> Still a bit miffed.  I'm not sure if it's beanutils that is not copying
> the List into the new bean... or if I can't figure out this nested tag.
> I put that code snippet into my JSP and changed the information around
> several times and I still don't see the info being printed on my page.
> I guess my next question is... is the JSP code different if I have a
> list of beans, as opposed to a single Bean stored in my bean.  I have
> the List.  Another OT question is, will beanutils copy a List of Beans
> into the new Bean as a List of beans?  i.e.
> List school = mgr.getSchoolList(id);
> 
> BeanUtils.copyProperties(information,  schools);
> 
> Thanks Guys!
> Brandon
>

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



Re: Nested Beans

2005-05-20 Thread Brandon Mercer
Hubert Rabago wrote:

>You might find the nested tags interesting:
>
><%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
>
>
>
>
>
>
> 
> 
>
>
>  
>
Still a bit miffed.  I'm not sure if it's beanutils that is not copying
the List into the new bean... or if I can't figure out this nested tag. 
I put that code snippet into my JSP and changed the information around
several times and I still don't see the info being printed on my page. 
I guess my next question is... is the JSP code different if I have a
list of beans, as opposed to a single Bean stored in my bean.  I have
the List.  Another OT question is, will beanutils copy a List of Beans
into the new Bean as a List of beans?  i.e.
List school = mgr.getSchoolList(id);

BeanUtils.copyProperties(information,  schools);

Thanks Guys!
Brandon

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



Re: Nested Beans

2005-05-20 Thread Brandon Mercer
Hubert Rabago wrote:

>You might find the nested tags interesting:
>
><%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
>
>
>
>
>
>
> 
> 
>
>
>
>Hubert
>  
>
Looks like what I want to do.  I'll go check it out, thanks for the link.
Brandon


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



Re: Nested Beans

2005-05-20 Thread Hubert Rabago
You might find the nested tags interesting:

<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>






 
 



Hubert

On 5/20/05, Brandon Mercer <[EMAIL PROTECTED]> wrote:
> Hello Everyone,
> I've got an easy one, that is stupifying me because of my tiredness.
> I've got a POJO with a List in it.  The List is a list of beans.  In my
> JSP page I'm trying to iterate over the list of beans.  Here goes:
> 
> public class Information {
> private String name = null;
> private String addr = null;
> private List School = null;
> 
> 
> School is a bean that looks like:
> 
> public class School {
> private String schoolname = null;
> private String location = null;
> }
> 
> Then I set that information in the session:
> session.setAttribute("information", information);
> 
> Each information bean will have a list of schools in it and I'd like to
> iterate over that list on the JSP page but I'm not sure how far I am
> from the truth!  :-P  Right now I've got:
> 
> 
> 
> 
>  
> Thanks for your help everyone.
> Brandon
>

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



Nested Beans

2005-05-20 Thread Brandon Mercer
Hello Everyone,
I've got an easy one, that is stupifying me because of my tiredness. 
I've got a POJO with a List in it.  The List is a list of beans.  In my
JSP page I'm trying to iterate over the list of beans.  Here goes:

public class Information {
private String name = null;
private String addr = null;
private List School = null;


School is a bean that looks like:

public class School {
private String schoolname = null;
private String location = null;
}

Then I set that information in the session:
session.setAttribute("information", information);

Each information bean will have a list of schools in it and I'd like to
iterate over that list on the JSP page but I'm not sure how far I am
from the truth!  :-P  Right now I've got:






RE: Validating DynaBean nested beans with a custom validator.

2005-01-12 Thread Daffin, Miles (Company IT)
Sorry for the outrageoulsy long-winded question. It really boiled down
to this: how to get the PersonFormBean off the Object bean generically.
The answer is to use PropertyUtils.getSimpleProperty(...).
(BeanUtils.getProperty returns a String.)

MD

> -Original Message-
> From: Kishore Senji [mailto:[EMAIL PROTECTED] 
> Sent: 11 January 2005 18:58
> To: Struts Users Mailing List
> Subject: Re: Validating DynaBean nested beans with a custom validator.
> 
> This shoud do it. Isn't it?
> 
> private static PersonFormBean getPersonFormBean(Object bean, 
> String property) throws java.lang.IllegalAccessException, 
> java.lang.reflect.InvocationTargetException,
> java.lang.NoSuchMethodException{
>
>return (PersonFormBean) BeanUtils.getProperty(bean, property); }
> 
> 
> 
> 
> 
> On Tue, 11 Jan 2005 11:39:53 -, Daffin, Miles (Company 
> IT) <[EMAIL PROTECTED]> wrote:
> > Dear All,
> > 
> > I have a DynaValidatorActionForm like this:
> > 
> > 
> > > type="org.apache.struts.validator.DynaValidatorActionForm">
> > type="java.lang.String" />
> > > size="0" />
> > > type="com.plok.validator.beans.PersonFormBean"/>
> >
> > 
> > 
> > When the related form is submitted the action adds the 
> 'newPerson' to 
> > the 'personList' and replaces newPerson, on the DynaBean, 
> with a new 
> > PersonFormBean. This all works fine. Now I want to add declarative 
> > validation for the newPerson, so only valid newPersons reach the 
> > action code that adds them to the list.
> > 
> > The thing is that PersonFormBeans (in this example) have a 
> start and 
> > end date (a period). The validation rules for these fields are:
> > * start date and end date must be dates (dd/MM/)
> > * start date must be before end date
> > * end date must be after or equal to today
> > * etc...
> > 
> > So, you see, apart from the first rule, this goes beyond 
> what can be 
> > achieved by plucking out the fields from the nested bean 
> and using the 
> > default set of simple field validators shipped with struts 
> (required, 
> > date etc.). (Even if you disagree that these validation 
> requirements 
> > cannot be met in using the default validators please read 
> on. This is 
> > just an example.)
> > 
> > I have created a new validator that I want to handle the 
> entire nested
> > PersonFormBean: personValidator.
> > 
> >  >name="personValidator"
> >classname="com.plok.validator.beans.PersonFormBeanValidator"
> >method="validatePerson"
> >methodParams="java.lang.Object,
> >  org.apache.commons.validator.ValidatorAction,
> >  org.apache.commons.validator.Field,
> >  org.apache.struts.action.ActionErrors,
> >  javax.servlet.http.HttpServletRequest"
> >msg="errors.person">
> > 
> > 
> > public static boolean validatePerson(Object bean, 
> ValidatorAction va, 
> > Field field, ActionErrors errors, HttpServletRequest request) {
> >PersonFormBean personFormBean =
> > somehowGetTheBloodyPersonFormBeanOffTheBean(bean);
> >// Do the validation directly on the personFormBean.
> >return true;
> > }
> > private static PersonFormBean
> > somehowGetTheBloodyPersonFormBeanOffTheBean(Object bean) {
> >// How do I implement this?
> >// It has to be generic, in case I change my mind about 
> the type of 
> > the bean,
> >// e.g. make it a simple bean with getters and setters 
> instead of 
> > using the DynaBean...
> >return null;
> > }
> > 
> > Would you:
> > a) grab the nested PersonFormBean from the main, parent 
> bean and then 
> > work directly with this? If so how? Is there a utility 
> method somewhere?
> > b) grab individual fields from the nested bean using 
> BeanUtils methods 
> > (or other - feel free to advise).
> > 
> > Your thoughts/urls would be appreciated.
> > 
> > Many thanks.
> > 
> > -Miles
> > 
> > Miles Daffin
> > Morgan Stanley
> > 20 Cabot Square | Canary Wharf | London E14 4QA | UK
> > Tel: +44 (0) 20 767 75119
> > [EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>
> > 
> > 
> > NOTICE: If received in error, please destroy and notify 
> sender.  Sender does not waive confidentiality or privilege, 
> and use is prohibited.
> > 
> >
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

 
NOTICE: If received in error, please destroy and notify sender.  Sender does 
not waive confidentiality or privilege, and use is prohibited. 
 

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



Re: Validating DynaBean nested beans with a custom validator.

2005-01-11 Thread Kishore Senji
This shoud do it. Isn't it?

private static PersonFormBean getPersonFormBean(Object bean, String property)
throws java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException,
java.lang.NoSuchMethodException{
   
   return (PersonFormBean) BeanUtils.getProperty(bean, property);
}





On Tue, 11 Jan 2005 11:39:53 -, Daffin, Miles (Company IT)
<[EMAIL PROTECTED]> wrote:
> Dear All,
> 
> I have a DynaValidatorActionForm like this:
> 
> 
> type="org.apache.struts.validator.DynaValidatorActionForm">
>
> size="0" />
> type="com.plok.validator.beans.PersonFormBean"/>
>
> 
> 
> When the related form is submitted the action adds the 'newPerson' to
> the 'personList' and replaces newPerson, on the DynaBean, with a new
> PersonFormBean. This all works fine. Now I want to add declarative
> validation for the newPerson, so only valid newPersons reach the action
> code that adds them to the list.
> 
> The thing is that PersonFormBeans (in this example) have a start and end
> date (a period). The validation rules for these fields are:
> * start date and end date must be dates (dd/MM/)
> * start date must be before end date
> * end date must be after or equal to today
> * etc...
> 
> So, you see, apart from the first rule, this goes beyond what can be
> achieved by plucking out the fields from the nested bean and using the
> default set of simple field validators shipped with struts (required,
> date etc.). (Even if you disagree that these validation requirements
> cannot be met in using the default validators please read on. This is
> just an example.)
> 
> I have created a new validator that I want to handle the entire nested
> PersonFormBean: personValidator.
> 
> name="personValidator"
>classname="com.plok.validator.beans.PersonFormBeanValidator"
>method="validatePerson"
>methodParams="java.lang.Object,
>  org.apache.commons.validator.ValidatorAction,
>  org.apache.commons.validator.Field,
>  org.apache.struts.action.ActionErrors,
>  javax.servlet.http.HttpServletRequest"
>msg="errors.person">
> 
> 
> public static boolean validatePerson(Object bean, ValidatorAction va,
> Field field, ActionErrors errors, HttpServletRequest request)
> {
>PersonFormBean personFormBean =
> somehowGetTheBloodyPersonFormBeanOffTheBean(bean);
>// Do the validation directly on the personFormBean.
>return true;
> }
> private static PersonFormBean
> somehowGetTheBloodyPersonFormBeanOffTheBean(Object bean)
> {
>// How do I implement this?
>// It has to be generic, in case I change my mind about the type of
> the bean,
>// e.g. make it a simple bean with getters and setters instead of
> using the DynaBean...
>return null;
> }
> 
> Would you:
> a) grab the nested PersonFormBean from the main, parent bean and then
> work directly with this? If so how? Is there a utility method somewhere?
> b) grab individual fields from the nested bean using BeanUtils methods
> (or other - feel free to advise).
> 
> Your thoughts/urls would be appreciated.
> 
> Many thanks.
> 
> -Miles
> 
> Miles Daffin
> Morgan Stanley
> 20 Cabot Square | Canary Wharf | London E14 4QA | UK
> Tel: +44 (0) 20 767 75119
> [EMAIL PROTECTED] 
> 
> 
> NOTICE: If received in error, please destroy and notify sender.  Sender does 
> not waive confidentiality or privilege, and use is prohibited.
> 
>

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



Validating DynaBean nested beans with a custom validator.

2005-01-11 Thread Daffin, Miles (Company IT)
Dear All,
 
I have a DynaValidatorActionForm like this:
 








When the related form is submitted the action adds the 'newPerson' to
the 'personList' and replaces newPerson, on the DynaBean, with a new
PersonFormBean. This all works fine. Now I want to add declarative
validation for the newPerson, so only valid newPersons reach the action
code that adds them to the list. 
 
The thing is that PersonFormBeans (in this example) have a start and end
date (a period). The validation rules for these fields are:
* start date and end date must be dates (dd/MM/)
* start date must be before end date
* end date must be after or equal to today
* etc...
 
So, you see, apart from the first rule, this goes beyond what can be
achieved by plucking out the fields from the nested bean and using the
default set of simple field validators shipped with struts (required,
date etc.). (Even if you disagree that these validation requirements
cannot be met in using the default validators please read on. This is
just an example.)
 
I have created a new validator that I want to handle the entire nested
PersonFormBean: personValidator.
 



 
public static boolean validatePerson(Object bean, ValidatorAction va,
Field field, ActionErrors errors, HttpServletRequest request)
{
PersonFormBean personFormBean =
somehowGetTheBloodyPersonFormBeanOffTheBean(bean);
// Do the validation directly on the personFormBean.
return true;
}
private static PersonFormBean
somehowGetTheBloodyPersonFormBeanOffTheBean(Object bean)
{
// How do I implement this?
// It has to be generic, in case I change my mind about the type of
the bean,
// e.g. make it a simple bean with getters and setters instead of
using the DynaBean...
return null;
}
 
Would you: 
a) grab the nested PersonFormBean from the main, parent bean and then
work directly with this? If so how? Is there a utility method somewhere?
b) grab individual fields from the nested bean using BeanUtils methods
(or other - feel free to advise).
 
Your thoughts/urls would be appreciated.
 
Many thanks.
 
-Miles
 
Miles Daffin
Morgan Stanley
20 Cabot Square | Canary Wharf | London E14 4QA | UK
Tel: +44 (0) 20 767 75119
[EMAIL PROTECTED]  

 
NOTICE: If received in error, please destroy and notify sender.  Sender does 
not waive confidentiality or privilege, and use is prohibited. 
 


Re: Struts Validator and Nested Beans

2004-11-22 Thread Hubert Rabago
The Validator plug in can recognize fields names such as
"employee.name", and that's the extent of my experience with it. 
Nested forms/tags allow you to go much deeper than that, and everytime
I do, I choose to use my own validate() implementation instead of
using Validator.

On Mon, 22 Nov 2004 09:46:32 -0500, David McReynolds
<[EMAIL PROTECTED]> wrote:
> I've not been able to find any examples so I was hoping someone may have
> tried this before. I am making copious use of nesting on my forms and I
> was wondering if this will prevent me from using the Struts validation
> framework?
> 
> --dlm
>

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



Struts Validator and Nested Beans

2004-11-22 Thread David McReynolds
I've not been able to find any examples so I was hoping someone may have
tried this before. I am making copious use of nesting on my forms and I
was wondering if this will prevent me from using the Struts validation
framework?

--dlm

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



Re: Properties of Nested Beans

2004-10-08 Thread Chris Stavrianou
I have narrowed the behaviour down somewhat - it appears to be related
to using capital letters in properties.

If I change the name of the LocationID String in the LocationBean from
locationID to LocationID I get the following error:

[ServletException in:/WEB-INF/jsp/admin/location/locselect.jsp] No
getter method for property LocationID of bean result'
javax.servlet.jsp.JspException: No getter method for property
LocationID of bean result at
org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:968) at
org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:286)
at 
org.apache.jsp.WEB_002dINF.jsp.admin.location.locselect_jsp._jspx_meth_bean_write_0(locselect_jsp.java:212)
at 
org.apache.jsp.WEB_002dINF.jsp.admin.location.locselect_jsp._jspService(locselect_jsp.java:124)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at 
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
at 
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:589)
at 
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:581)
at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:137)
at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:177) at
org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:756)
at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:881)
at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:473)
at 
org.apache.jsp.WEB_002dINF.jsp.HBFlayout_jsp._jspx_meth_tiles_insert_1(HBFlayout_jsp.java:165)
at org.apache.jsp.WEB_002dINF.jsp.HBFlayout_jsp._jspService(HBFlayout_jsp.java:100)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java

See following:

-Location Bean

public class Location implements Serializable {


private String  locationName, locationID;


public Location (String locationID,String locationName) {
this.locationID = locationID;
this.locationName = locationName;
}


public String getlocationID (){
return locationID;
}

public void setlocationID (String locationID){
this.locationID = locationID;
}   

public String getlocationName (){
return locationName;
}

public void setlocationName (String locationName){
this.locationName = locationName;
}


}



ArrayList results = new ArrayList();

String stmt = "select * from location where orgID = ? order by locationName;";

try {
PreparedStatement pstmt = conn.prepareStatement(stmt);
pstmt.setInt(1,orgID.intValue());
ResultSet RS = pstmt.executeQuery();

while (RS.next()){
results.add(
new Location(
RS.getString("LocationID"),
RS.getString("locationName")
)
); }
form.set("locations",results);

---JSP

LocationName




Edit

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



Re: Properties of Nested Beans

2004-10-08 Thread Yves Sy
Try keyboardmonkey.com

It has good stuff on nested tags which is what probably need.

-Yves-

On Fri, 08 Oct 2004 11:39:27 -0400, Bill Siggelkow
<[EMAIL PROTECTED]> wrote:
> There is no such restriction -- please provide some code so we can help
> diagnose your problem.
> 
> -Bill Siggelkow
> 
> 
> 
> Chris Stavrianou wrote:
> > HI all,
> >
> > I am having a problem with collections of beans nested within beans.
> >
> > I have found that I can only nested beans and get property names if
> > the property names are unique across the entire application.
> >
> > Is this a usual quirk of the way Struts uses reflection?
> >
> > Are there restrictions on reusing names through form beans and other
> > beans across the scope of a web-application?
> >
> > Thanks
> >
> > C.S.
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
For me to poop on!
http://www.formetopoopon.com
http://www.nbc.com/nbc/Late_Night_with_Conan_O'Brien/video/triumph.shtml

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



Re: Properties of Nested Beans

2004-10-08 Thread Bill Siggelkow
There is no such restriction -- please provide some code so we can help 
diagnose your problem.

-Bill Siggelkow
Chris Stavrianou wrote:
HI all,
I am having a problem with collections of beans nested within beans.
I have found that I can only nested beans and get property names if
the property names are unique across the entire application.
Is this a usual quirk of the way Struts uses reflection?
Are there restrictions on reusing names through form beans and other
beans across the scope of a web-application?
Thanks
C.S.

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


Properties of Nested Beans

2004-10-08 Thread Chris Stavrianou
HI all,

I am having a problem with collections of beans nested within beans.

I have found that I can only nested beans and get property names if
the property names are unique across the entire application.

Is this a usual quirk of the way Struts uses reflection?

Are there restrictions on reusing names through form beans and other
beans across the scope of a web-application?

Thanks

C.S.

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



nested beans and validation?

2004-05-06 Thread Simon Pett
Hi 

 

I have a subclass of DynaValidatorForm with nested Forms, some in a list
others just singular

 

This works ok however I want to sort the validation out. 

 

After searching the list the only solution I have found is to add each
nested form's validation to the top level form in the validation.xml using
dot notation. This works fine but each time I want to reuse a nested form I
have to duplicate the validation rules

 

Ideas ?

 

Thanks

Simon