You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Petzsch, Martin" <ma...@capgemini.com> on 2007/08/09 16:40:16 UTC

[s2] @ConversionErrorFieldValidator and Collections

Hi,

I posted this a few days ago but have had no response as yet.  I will
probably raise this as an issue/bug soon unless it is obvious to someone on
here that I have a mistake in my approach.

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

I have a data bean which a jsp links into through an action.  This bean
contains a date field. I annotate the set method with:
	@ConversionErrorFieldValidator(message="aDate: Conversion Error")
	@RequiredFieldValidator(message="aDate: Required Field")
	public void setADate(Date date) {
		aDate = date;
	}

This works fine and I get the messages about type conversion and validation
failure in the expected order depending on my input.

The same data bean also contains a List of another data bean and the
associated methods:
	private List<InnerBean> innerList;
	@VisitorFieldValidator(message="Inner Message:",appendPrefix=true)
	public List<InnerBean> getInnerList() {
		if (innerList == null) {
			innerList = new ArrayList<InnerBean>();
			innerList.add(new InnerBean());
		}
		return innerList;
	}

	public void setInnerList(List<InnerBean> innerList) {
		this.innerList = innerList;
	}

My inner bean is as follows:
	private Date innerProp;
	public Date getInnerProp(){
		return innerProp;
	}
	
	@ConversionErrorFieldValidator(message="innerProp: Conversion
Error")
	@RequiredFieldValidator(message="innerProp: Required Field")
	public void setInnerProp(Date str){
		innerProp = str;
	}

The required field validator works as expected.  I do not however get any
result EVER back from the ConversionErrorFieldValidator on the inner bean.
If I enter an incorrect value it simply does not get set.

Does anyone have a working example of ConversionErrorFieldValidator inside a
bean which is inside a collection?

Many thanks,
Martin


Source Code Follows
===============================================
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import
com.opensymphony.xwork2.validator.annotations.ConversionErrorFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
import com.opensymphony.xwork2.validator.annotations.VisitorFieldValidator;

public class MyDataBean {
	private Date aDate;
	private List<InnerBean> innerList;	
	
	public MyDataBean() {
	}

	@VisitorFieldValidator(message="Inner Message",appendPrefix=false)
	public List<InnerBean> getInnerList() {
		if (innerList == null) {
			innerList = new ArrayList<InnerBean>();
			innerList.add(new InnerBean());
		}
		return innerList;
	}

	public void setInnerList(List<InnerBean> innerList) {
		this.innerList = innerList;
	}

	public Date getADate() {
		return aDate;
	}

	// this works fine
	@ConversionErrorFieldValidator(message="aDate: Conversion Error")
	@RequiredFieldValidator(message="aDate: Required Field")
	public void setADate(Date date) {
		aDate = date;
	}
}
--------
/**
 * 
 */
import java.util.Date;

import
com.opensymphony.xwork2.validator.annotations.ConversionErrorFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;

/**
 * @author MPETZSCH
 *
 */
public class InnerBean {
	private Date innerProp;
	
	public Date getInnerProp(){
		return innerProp;
	}
	
	// this does not work
	@ConversionErrorFieldValidator(message="innerProp: Conversion
Error")
	@RequiredFieldValidator(message="innerProp: Required Field")
	public void setInnerProp(Date str){
		innerProp = str;
	}
}


Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. 


This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.


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


RE: [s2] @ConversionErrorFieldValidator and Collections

Posted by "Petzsch, Martin" <ma...@capgemini.com>.
I have now posted this as a bug on JIRA.

https://issues.apache.org/struts/browse/WW-2112 

Kind regards,
Martin

-----Original Message-----
From: Petzsch, Martin [mailto:martin.petzsch@capgemini.com] 
Sent: 09 August 2007 15:40
To: Struts Users Mailing List
Subject: [s2] @ConversionErrorFieldValidator and Collections


Hi,

I posted this a few days ago but have had no response as yet.  I will
probably raise this as an issue/bug soon unless it is obvious to someone on
here that I have a mistake in my approach.

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

I have a data bean which a jsp links into through an action.  This bean
contains a date field. I annotate the set method with:
	@ConversionErrorFieldValidator(message="aDate: Conversion Error")
	@RequiredFieldValidator(message="aDate: Required Field")
	public void setADate(Date date) {
		aDate = date;
	}

This works fine and I get the messages about type conversion and validation
failure in the expected order depending on my input.

The same data bean also contains a List of another data bean and the
associated methods:
	private List<InnerBean> innerList;
	@VisitorFieldValidator(message="Inner Message:",appendPrefix=true)
	public List<InnerBean> getInnerList() {
		if (innerList == null) {
			innerList = new ArrayList<InnerBean>();
			innerList.add(new InnerBean());
		}
		return innerList;
	}

	public void setInnerList(List<InnerBean> innerList) {
		this.innerList = innerList;
	}

My inner bean is as follows:
	private Date innerProp;
	public Date getInnerProp(){
		return innerProp;
	}
	
	@ConversionErrorFieldValidator(message="innerProp: Conversion
Error")
	@RequiredFieldValidator(message="innerProp: Required Field")
	public void setInnerProp(Date str){
		innerProp = str;
	}

The required field validator works as expected.  I do not however get any
result EVER back from the ConversionErrorFieldValidator on the inner bean.
If I enter an incorrect value it simply does not get set.

Does anyone have a working example of ConversionErrorFieldValidator inside a
bean which is inside a collection?

Many thanks,
Martin


Source Code Follows
===============================================
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import
com.opensymphony.xwork2.validator.annotations.ConversionErrorFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
import com.opensymphony.xwork2.validator.annotations.VisitorFieldValidator;

public class MyDataBean {
	private Date aDate;
	private List<InnerBean> innerList;	
	
	public MyDataBean() {
	}

	@VisitorFieldValidator(message="Inner Message",appendPrefix=false)
	public List<InnerBean> getInnerList() {
		if (innerList == null) {
			innerList = new ArrayList<InnerBean>();
			innerList.add(new InnerBean());
		}
		return innerList;
	}

	public void setInnerList(List<InnerBean> innerList) {
		this.innerList = innerList;
	}

	public Date getADate() {
		return aDate;
	}

	// this works fine
	@ConversionErrorFieldValidator(message="aDate: Conversion Error")
	@RequiredFieldValidator(message="aDate: Required Field")
	public void setADate(Date date) {
		aDate = date;
	}
}
--------
/**
 * 
 */
import java.util.Date;

import
com.opensymphony.xwork2.validator.annotations.ConversionErrorFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;

/**
 * @author MPETZSCH
 *
 */
public class InnerBean {
	private Date innerProp;
	
	public Date getInnerProp(){
		return innerProp;
	}
	
	// this does not work
	@ConversionErrorFieldValidator(message="innerProp: Conversion
Error")
	@RequiredFieldValidator(message="innerProp: Required Field")
	public void setInnerProp(Date str){
		innerProp = str;
	}
}


Capgemini is a trading name used by the Capgemini Group of companies which
includes Capgemini UK plc, a company registered in England and Wales (number
943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21
6DB. 


This message contains information that may be privileged or confidential and
is the property of the Capgemini Group. It is intended only for the person
to whom it is addressed. If you are not the intended recipient,  you are not
authorized to read, print, retain, copy, disseminate,  distribute, or use
this message or any part thereof. If you receive this  message in error,
please notify the sender immediately and delete all  copies of this message.


This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.


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


RE: [s2] @ConversionErrorFieldValidator and Collections

Posted by "Petzsch, Martin" <ma...@capgemini.com>.
Does anyone know what the release date for 2.0.11 is?  This bug is now
scheduled to be fixed in that release.

Kind regards,
Martin

-----Original Message-----
From: Petzsch, Martin 
Sent: 14 August 2007 16:53
To: Struts Users Mailing List
Subject: RE: [s2] @ConversionErrorFieldValidator and Collections

I have now posted this as a bug on JIRA.

https://issues.apache.org/struts/browse/WW-2112 

Kind regards,
Martin

-----Original Message-----
From: Petzsch, Martin [mailto:martin.petzsch@capgemini.com] 
Sent: 09 August 2007 15:40
To: Struts Users Mailing List
Subject: [s2] @ConversionErrorFieldValidator and Collections


Hi,

I posted this a few days ago but have had no response as yet.  I will
probably raise this as an issue/bug soon unless it is obvious to someone on
here that I have a mistake in my approach.

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

I have a data bean which a jsp links into through an action.  This bean
contains a date field. I annotate the set method with:
	@ConversionErrorFieldValidator(message="aDate: Conversion Error")
	@RequiredFieldValidator(message="aDate: Required Field")
	public void setADate(Date date) {
		aDate = date;
	}

This works fine and I get the messages about type conversion and validation
failure in the expected order depending on my input.

The same data bean also contains a List of another data bean and the
associated methods:
	private List<InnerBean> innerList;
	@VisitorFieldValidator(message="Inner Message:",appendPrefix=true)
	public List<InnerBean> getInnerList() {
		if (innerList == null) {
			innerList = new ArrayList<InnerBean>();
			innerList.add(new InnerBean());
		}
		return innerList;
	}

	public void setInnerList(List<InnerBean> innerList) {
		this.innerList = innerList;
	}

My inner bean is as follows:
	private Date innerProp;
	public Date getInnerProp(){
		return innerProp;
	}
	
	@ConversionErrorFieldValidator(message="innerProp: Conversion
Error")
	@RequiredFieldValidator(message="innerProp: Required Field")
	public void setInnerProp(Date str){
		innerProp = str;
	}

The required field validator works as expected.  I do not however get any
result EVER back from the ConversionErrorFieldValidator on the inner bean.
If I enter an incorrect value it simply does not get set.

Does anyone have a working example of ConversionErrorFieldValidator inside a
bean which is inside a collection?

Many thanks,
Martin


Source Code Follows
===============================================
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import
com.opensymphony.xwork2.validator.annotations.ConversionErrorFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
import com.opensymphony.xwork2.validator.annotations.VisitorFieldValidator;

public class MyDataBean {
	private Date aDate;
	private List<InnerBean> innerList;	
	
	public MyDataBean() {
	}

	@VisitorFieldValidator(message="Inner Message",appendPrefix=false)
	public List<InnerBean> getInnerList() {
		if (innerList == null) {
			innerList = new ArrayList<InnerBean>();
			innerList.add(new InnerBean());
		}
		return innerList;
	}

	public void setInnerList(List<InnerBean> innerList) {
		this.innerList = innerList;
	}

	public Date getADate() {
		return aDate;
	}

	// this works fine
	@ConversionErrorFieldValidator(message="aDate: Conversion Error")
	@RequiredFieldValidator(message="aDate: Required Field")
	public void setADate(Date date) {
		aDate = date;
	}
}
--------
/**
 * 
 */
import java.util.Date;

import
com.opensymphony.xwork2.validator.annotations.ConversionErrorFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;

/**
 * @author MPETZSCH
 *
 */
public class InnerBean {
	private Date innerProp;
	
	public Date getInnerProp(){
		return innerProp;
	}
	
	// this does not work
	@ConversionErrorFieldValidator(message="innerProp: Conversion
Error")
	@RequiredFieldValidator(message="innerProp: Required Field")
	public void setInnerProp(Date str){
		innerProp = str;
	}
}


Capgemini is a trading name used by the Capgemini Group of companies which
includes Capgemini UK plc, a company registered in England and Wales (number
943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21
6DB. 


This message contains information that may be privileged or confidential and
is the property of the Capgemini Group. It is intended only for the person
to whom it is addressed. If you are not the intended recipient,  you are not
authorized to read, print, retain, copy, disseminate,  distribute, or use
this message or any part thereof. If you receive this  message in error,
please notify the sender immediately and delete all  copies of this message.


This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.


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