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]

Reply via email to