Re: Struts Validation Rule for Single Java Bean form-property

2005-10-29 Thread Martin Gainty

Yujun-
You can reference locale specific strings with bean:message.. for 
implementation details take a look at Rick Reumanns page

http://www.reumann.net/struts/lesson3/step9.do
and of course implementing locale specific strings dentified within 
ApplicationResources.properties
(in your case it might be ApplicationResources_cn.properties file) ..I 
encourage you to look at the english example at

http://www.reumann.net/struts/lesson3/step7.do
Kind Regards,
Martin-

- Original Message - 
From: Laurie Harper [EMAIL PROTECTED]

To: user@struts.apache.org
Sent: Friday, October 28, 2005 8:28 PM
Subject: Re: Struts Validation Rule for Single Java Bean form-property



Yujun Liang wrote:

Laurie,

Thanks for the suggestion, just let you know I tried that and it seems 
not working, thus I am not sure whether this can be enhanced by Struts 
team since Java Bean inside Form Bean is a valid configuration and it is 
a very nice feature but there still something to imrprove.


For example, it can't handle Locale and java.util.Date which I sent out 
another seperate email and you replied as well. But the Bean Population 
is handled by Struts so I can't register my converter unless I modify 
common BeanUtil.


That, at least, is not true. See ConvertUtils.register() for registering 
custom converters on the default ConvertUtilsBean / BeanUtilsBean combo. 
Just make sure you register your converter during startup (using a context 
listener, servlet or Struts plugin) so they're available when form 
processing starts.


L.



Thanks.

Regards
Yujun Liang
[EMAIL PROTECTED]
(0408) 467 448
- Original Message - From: Laurie Harper [EMAIL PROTECTED]
To: user@struts.apache.org
Sent: Saturday, October 29, 2005 1:51 AM
Subject: Re: Struts Validation Rule for Single Java Bean form-property


Hmm, I'm not sure how to specify the validation rules with that 
configuration; you could try with field property=mybean.creationTime 
depends=...


L.

Yujun Liang wrote:


Hello,

I define a single Java Bean Form Bean, do you know how to define the 
validation rule? Thanks.


Regards
Yujun Liang
[EMAIL PROTECTED]
(0408) 467 448


1. Form Bean Definition,
form-bean name=myForm 
type=org.apache.struts.validator.DynaValidatorForm


form-property name=mybean 
type=com.mycompany.myproject.bean.MyBean/


/form-bean

2. Java Bean,

package com.mycompany.myproject.bean;

import java.io.Serializable;

import java.sql.Timestamp;

import org.apache.commons.lang.builder.EqualsBuilder;

import org.apache.commons.lang.builder.HashCodeBuilder;

import org.apache.commons.lang.builder.ToStringBuilder;

public class MyBean implements Serializable {

private long interchangeId;

private Timestamp creationTime;

private String originatingChannel;

public long getInterchangeId() {

return this.interchangeId;

}

public void setInterchangeId(long interchangeId) {

this.interchangeId = interchangeId;

}

public Timestamp getCreationTime() {

return this.creationTime;

}


public void setCreationTime(Timestamp creationTime) { 
this.creationTime = creationTime;


}


public String getOriginatingChannel() {

return this.originatingChannel;

}

public void setOriginatingChannel(String originatingChannel) {

this.originatingChannel = originatingChannel;

}

}

3. HTML Form

input name=mybean.creationTime type=text size=30 maxlength=30 
value=25/10/2005
input name=mybean.originatingChannel type=text size=40 
maxlength=40 value=originating channel1
input name=mybean.originatingChannelUserId type=text size=60 
maxlength=60 value=originating_channel_userid1





-
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 Validation Rule for Single Java Bean form-property

2005-10-29 Thread Yujun Liang
Martin,

Thanks for your help. My problem was not displaying the bean. What I wanted
to know is whether there is a way to validate the property of the Java Bean
defined in the form bean.

How to define the validation rule for
input name=mybean.creationTime

Source code.

 1. Form Bean Definition,

form-bean name=myForm type=org.apache.struts.validator.DynaValidatorForm


form-property name=mybean type=com.mycompany.myproject.bean.MyBean/

/form-bean

2. Java Bean,

*package* com.mycompany.myproject.bean;
* *

*import* java.io.Serializable;
* *

*import* java.sql.Timestamp;
* *

*import* org.apache.commons.lang.builder.EqualsBuilder;
* *

*import* org.apache.commons.lang.builder.HashCodeBuilder;
* *

*import* org.apache.commons.lang.builder.ToStringBuilder;

*public* *abstract* *class* MyBean *implements* Serializable {

* private* *long* interchangeId;

* private* Timestamp creationTime;

* private* String originatingChannel;

* public* *long* getInterchangeId() {

* return* *this*.interchangeId;

}

* public **void* setInterchangeId(*long* interchangeId) {

* this*.interchangeId = interchangeId;

}

* public* Timestamp getCreationTime() {

* return* *this*.creationTime;

}

* *
* public* *void* setCreationTime(Timestamp creationTime) {

* this*.creationTime = creationTime;

}

* public* String getOriginatingChannel() {

* return* *this*.originatingChannel;

}

* public* *void* setOriginatingChannel(String originatingChannel) {

* this*.originatingChannel = originatingChannel;

}

}

3. HTML Form

input name=mybean.creationTime type=text size=30 maxlength=30
value=25/10/2005
input name=mybean.originatingChannel type=text size=40 maxlength=40
value=originating channel1
input name=mybean.originatingChannelUserId type=text size=60
maxlength=60 value=originating_channel_userid1


On 10/29/05, Martin Gainty [EMAIL PROTECTED] wrote:

 Yujun-
 You can reference locale specific strings with bean:message.. for
 implementation details take a look at Rick Reumanns page
 http://www.reumann.net/struts/lesson3/step9.do
 and of course implementing locale specific strings dentified within
 ApplicationResources.properties
 (in your case it might be ApplicationResources_cn.properties file) ..I
 encourage you to look at the english example at
 http://www.reumann.net/struts/lesson3/step7.do
 Kind Regards,
 Martin-

 - Original Message -
 From: Laurie Harper [EMAIL PROTECTED]
 To: user@struts.apache.org
 Sent: Friday, October 28, 2005 8:28 PM
 Subject: Re: Struts Validation Rule for Single Java Bean form-property


  Yujun Liang wrote:
  Laurie,
 
  Thanks for the suggestion, just let you know I tried that and it seems
  not working, thus I am not sure whether this can be enhanced by Struts
  team since Java Bean inside Form Bean is a valid configuration and it
 is
  a very nice feature but there still something to imrprove.
 
  For example, it can't handle Locale and java.util.Date which I sent out
  another seperate email and you replied as well. But the Bean Population
  is handled by Struts so I can't register my converter unless I modify
  common BeanUtil.
 
  That, at least, is not true. See ConvertUtils.register() for registering
  custom converters on the default ConvertUtilsBean / BeanUtilsBean combo.
  Just make sure you register your converter during startup (using a
 context
  listener, servlet or Struts plugin) so they're available when form
  processing starts.
 
  L.
 
 
  Thanks.
 
  Regards
  Yujun Liang
  [EMAIL PROTECTED]
  (0408) 467 448
  - Original Message - From: Laurie Harper [EMAIL PROTECTED]
  To: user@struts.apache.org
  Sent: Saturday, October 29, 2005 1:51 AM
  Subject: Re: Struts Validation Rule for Single Java Bean form-property
 
 
  Hmm, I'm not sure how to specify the validation rules with that
  configuration; you could try with field property=mybean.creationTime
 
  depends=...
 
  L.
 
  Yujun Liang wrote:
 
  Hello,
 
  I define a single Java Bean Form Bean, do you know how to define the
  validation rule? Thanks.
 
  Regards
  Yujun Liang
  [EMAIL PROTECTED]
  (0408) 467 448
 
 
  1. Form Bean Definition,
  form-bean name=myForm
  type=org.apache.struts.validator.DynaValidatorForm
 
  form-property name=mybean
  type=com.mycompany.myproject.bean.MyBean/
 
  /form-bean
 
  2. Java Bean,
 
  package com.mycompany.myproject.bean;
 
  import java.io.Serializable;
 
  import java.sql.Timestamp;
 
  import org.apache.commons.lang.builder.EqualsBuilder;
 
  import org.apache.commons.lang.builder.HashCodeBuilder;
 
  import org.apache.commons.lang.builder.ToStringBuilder;
 
  public class MyBean implements Serializable {
 
  private long interchangeId;
 
  private Timestamp creationTime;
 
  private String originatingChannel;
 
  public long getInterchangeId() {
 
  return this.interchangeId;
 
  }
 
  public void setInterchangeId(long interchangeId) {
 
  this.interchangeId = interchangeId;
 
  }
 
  public Timestamp getCreationTime() {
 
  return this.creationTime

Re: Struts Validation Rule for Single Java Bean form-property

2005-10-28 Thread Laurie Harper
Hmm, I'm not sure how to specify the validation rules with that 
configuration; you could try with field property=mybean.creationTime 
depends=...


L.

Yujun Liang wrote:

Hello,

I define a single Java Bean Form Bean, do you know how to define the validation 
rule? Thanks.

Regards
Yujun Liang
[EMAIL PROTECTED]
(0408) 467 448


1. Form Bean Definition,
form-bean name=myForm type=org.apache.struts.validator.DynaValidatorForm

form-property name=mybean type=com.mycompany.myproject.bean.MyBean/

/form-bean

2. Java Bean,

package com.mycompany.myproject.bean;

import java.io.Serializable;

import java.sql.Timestamp;

import org.apache.commons.lang.builder.EqualsBuilder;

import org.apache.commons.lang.builder.HashCodeBuilder;

import org.apache.commons.lang.builder.ToStringBuilder;

public class MyBean implements Serializable {

private long interchangeId;

private Timestamp creationTime;

private String originatingChannel;

public long getInterchangeId() {

return this.interchangeId;

}

public void setInterchangeId(long interchangeId) {

this.interchangeId = interchangeId;

}

public Timestamp getCreationTime() {

return this.creationTime;

}


public void setCreationTime(Timestamp creationTime) { 


this.creationTime = creationTime;

}


public String getOriginatingChannel() {

return this.originatingChannel;

}

public void setOriginatingChannel(String originatingChannel) {

this.originatingChannel = originatingChannel;

}

}

3. HTML Form

input name=mybean.creationTime type=text size=30 maxlength=30 
value=25/10/2005
input name=mybean.originatingChannel type=text size=40 maxlength=40 
value=originating channel1
input name=mybean.originatingChannelUserId type=text size=60 maxlength=60 
value=originating_channel_userid1




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



Re: Struts Validation Rule for Single Java Bean form-property

2005-10-28 Thread Yujun Liang

Laurie,

Thanks for the suggestion, just let you know I tried that and it seems not 
working, thus I am not sure whether this can be enhanced by Struts team 
since Java Bean inside Form Bean is a valid configuration and it is a very 
nice feature but there still something to imrprove.


For example, it can't handle Locale and java.util.Date which I sent out 
another seperate email and you replied as well. But the Bean Population is 
handled by Struts so I can't register my converter unless I modify common 
BeanUtil.


Thanks.

Regards
Yujun Liang
[EMAIL PROTECTED]
(0408) 467 448
- Original Message - 
From: Laurie Harper [EMAIL PROTECTED]

To: user@struts.apache.org
Sent: Saturday, October 29, 2005 1:51 AM
Subject: Re: Struts Validation Rule for Single Java Bean form-property


Hmm, I'm not sure how to specify the validation rules with that 
configuration; you could try with field property=mybean.creationTime 
depends=...


L.

Yujun Liang wrote:

Hello,

I define a single Java Bean Form Bean, do you know how to define the 
validation rule? Thanks.


Regards
Yujun Liang
[EMAIL PROTECTED]
(0408) 467 448


1. Form Bean Definition,
form-bean name=myForm 
type=org.apache.struts.validator.DynaValidatorForm


form-property name=mybean 
type=com.mycompany.myproject.bean.MyBean/


/form-bean

2. Java Bean,

package com.mycompany.myproject.bean;

import java.io.Serializable;

import java.sql.Timestamp;

import org.apache.commons.lang.builder.EqualsBuilder;

import org.apache.commons.lang.builder.HashCodeBuilder;

import org.apache.commons.lang.builder.ToStringBuilder;

public class MyBean implements Serializable {

private long interchangeId;

private Timestamp creationTime;

private String originatingChannel;

public long getInterchangeId() {

return this.interchangeId;

}

public void setInterchangeId(long interchangeId) {

this.interchangeId = interchangeId;

}

public Timestamp getCreationTime() {

return this.creationTime;

}


public void setCreationTime(Timestamp creationTime) { 
this.creationTime = creationTime;


}


public String getOriginatingChannel() {

return this.originatingChannel;

}

public void setOriginatingChannel(String originatingChannel) {

this.originatingChannel = originatingChannel;

}

}

3. HTML Form

input name=mybean.creationTime type=text size=30 maxlength=30 
value=25/10/2005
input name=mybean.originatingChannel type=text size=40 
maxlength=40 value=originating channel1
input name=mybean.originatingChannelUserId type=text size=60 
maxlength=60 value=originating_channel_userid1





-
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 Validation Rule for Single Java Bean form-property

2005-10-28 Thread Laurie Harper

Yujun Liang wrote:

Laurie,

Thanks for the suggestion, just let you know I tried that and it seems 
not working, thus I am not sure whether this can be enhanced by Struts 
team since Java Bean inside Form Bean is a valid configuration and it is 
a very nice feature but there still something to imrprove.


For example, it can't handle Locale and java.util.Date which I sent out 
another seperate email and you replied as well. But the Bean Population 
is handled by Struts so I can't register my converter unless I modify 
common BeanUtil.


That, at least, is not true. See ConvertUtils.register() for registering 
custom converters on the default ConvertUtilsBean / BeanUtilsBean combo. 
Just make sure you register your converter during startup (using a 
context listener, servlet or Struts plugin) so they're available when 
form processing starts.


L.



Thanks.

Regards
Yujun Liang
[EMAIL PROTECTED]
(0408) 467 448
- Original Message - From: Laurie Harper [EMAIL PROTECTED]
To: user@struts.apache.org
Sent: Saturday, October 29, 2005 1:51 AM
Subject: Re: Struts Validation Rule for Single Java Bean form-property


Hmm, I'm not sure how to specify the validation rules with that 
configuration; you could try with field 
property=mybean.creationTime depends=...


L.

Yujun Liang wrote:


Hello,

I define a single Java Bean Form Bean, do you know how to define the 
validation rule? Thanks.


Regards
Yujun Liang
[EMAIL PROTECTED]
(0408) 467 448


1. Form Bean Definition,
form-bean name=myForm 
type=org.apache.struts.validator.DynaValidatorForm


form-property name=mybean 
type=com.mycompany.myproject.bean.MyBean/


/form-bean

2. Java Bean,

package com.mycompany.myproject.bean;

import java.io.Serializable;

import java.sql.Timestamp;

import org.apache.commons.lang.builder.EqualsBuilder;

import org.apache.commons.lang.builder.HashCodeBuilder;

import org.apache.commons.lang.builder.ToStringBuilder;

public class MyBean implements Serializable {

private long interchangeId;

private Timestamp creationTime;

private String originatingChannel;

public long getInterchangeId() {

return this.interchangeId;

}

public void setInterchangeId(long interchangeId) {

this.interchangeId = interchangeId;

}

public Timestamp getCreationTime() {

return this.creationTime;

}


public void setCreationTime(Timestamp creationTime) { 
this.creationTime = creationTime;


}


public String getOriginatingChannel() {

return this.originatingChannel;

}

public void setOriginatingChannel(String originatingChannel) {

this.originatingChannel = originatingChannel;

}

}

3. HTML Form

input name=mybean.creationTime type=text size=30 
maxlength=30 value=25/10/2005
input name=mybean.originatingChannel type=text size=40 
maxlength=40 value=originating channel1
input name=mybean.originatingChannelUserId type=text size=60 
maxlength=60 value=originating_channel_userid1





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



Struts Validation Rule for Single Java Bean form-property

2005-10-27 Thread Yujun Liang
Hello,

I define a single Java Bean Form Bean, do you know how to define the validation 
rule? Thanks.

Regards
Yujun Liang
[EMAIL PROTECTED]
(0408) 467 448


1. Form Bean Definition,
form-bean name=myForm type=org.apache.struts.validator.DynaValidatorForm

form-property name=mybean type=com.mycompany.myproject.bean.MyBean/

/form-bean

2. Java Bean,

package com.mycompany.myproject.bean;

import java.io.Serializable;

import java.sql.Timestamp;

import org.apache.commons.lang.builder.EqualsBuilder;

import org.apache.commons.lang.builder.HashCodeBuilder;

import org.apache.commons.lang.builder.ToStringBuilder;

public class MyBean implements Serializable {

private long interchangeId;

private Timestamp creationTime;

private String originatingChannel;

public long getInterchangeId() {

return this.interchangeId;

}

public void setInterchangeId(long interchangeId) {

this.interchangeId = interchangeId;

}

public Timestamp getCreationTime() {

return this.creationTime;

}


public void setCreationTime(Timestamp creationTime) { 

this.creationTime = creationTime;

}


public String getOriginatingChannel() {

return this.originatingChannel;

}

public void setOriginatingChannel(String originatingChannel) {

this.originatingChannel = originatingChannel;

}

}

3. HTML Form

input name=mybean.creationTime type=text size=30 maxlength=30 
value=25/10/2005
input name=mybean.originatingChannel type=text size=40 maxlength=40 
value=originating channel1
input name=mybean.originatingChannelUserId type=text size=60 
maxlength=60 value=originating_channel_userid1