You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "K.P.Bhat" <kp...@india.hp.com> on 2002/11/19 14:47:38 UTC

Query regarding initialization of jsp form


Hi,

I am facing the following issue with regard to jsp form initialization by
struts
When a primitive data type such as int or double is used in the form bean ,
the corresponding jsp shows the
form elment initialized to 0 or 0.0 as the case may be.
	 How do i prevent this from happening ?

However if the form bean attribute carries a valid value (say 5 or 6.56 etc)
, then the same must be displayed on the jsp.


Let me enumerate with an example

Suppose the form bean look like this

	FromBeanA.java
	{
		double age ;

		public void setAge(double age)
		{
		this.age = age;
		}

		public double getAge()
		{
			return this.age
		}
	}

--- And the jsp has the following

<html:form action="/xyz.do" >
--------------
-----------
<!-- here form bean is assumed to be appropriately configured -->
Age = 	<html:text name="FromBeanA" property="age" />


<html:form/>

then  the display of the jsp will look like this

		Age = 0.0

I do not want 0.0 to appear


Thanks in advance,

	Prakash













--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Query regarding initialization of jsp form

Posted by Andrew Hill <an...@gridnode.com>.
Thats why its better to always use Strings for the form properties and
convert to the appropriate type for the business logic back in the action.

-----Original Message-----
From: K.P.Bhat [mailto:kpbhat@india.hp.com]
Sent: Tuesday, November 19, 2002 21:48
To: 'Struts Users Mailing List'
Subject: Query regarding initialization of jsp form




Hi,

I am facing the following issue with regard to jsp form initialization by
struts
When a primitive data type such as int or double is used in the form bean ,
the corresponding jsp shows the
form elment initialized to 0 or 0.0 as the case may be.
	 How do i prevent this from happening ?

However if the form bean attribute carries a valid value (say 5 or 6.56 etc)
, then the same must be displayed on the jsp.


Let me enumerate with an example

Suppose the form bean look like this

	FromBeanA.java
	{
		double age ;

		public void setAge(double age)
		{
		this.age = age;
		}

		public double getAge()
		{
			return this.age
		}
	}

--- And the jsp has the following

<html:form action="/xyz.do" >
--------------
-----------
<!-- here form bean is assumed to be appropriately configured -->
Age = 	<html:text name="FromBeanA" property="age" />


<html:form/>

then  the display of the jsp will look like this

		Age = 0.0

I do not want 0.0 to appear


Thanks in advance,

	Prakash













--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>