<html:text> <html:select>, blank fields and "please select" ... How to??
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   joey_corleon
Posted On:   Monday, July 15, 2002 01:00 PM

Hi, In my ActionForm, I have 2 attributes: String email = null; int age = -1; (initialised within the constructor) I then code the following code within my JSP to display these fields to be edited: My question is the following: When I display these attributes for the very first time on the browser, as expected the field "email" is BLANK (nothing at all in the field), waiting for the user's input (as the String object associated to this filed has been initialized to null within the constructor of the actionForm) - HOWEVER, the field "age" displays "-1" (which is understand   More>>

Hi,



In my ActionForm, I have 2 attributes:



			
String email = null;

int age = -1;


(initialised within the constructor)



I then code the following code within my JSP to display these fields to be edited:

			





My question is the following:

When I display these attributes for the very first time on the browser, as expected the field "email" is BLANK (nothing at all in the field), waiting for the user's input (as the String object associated to this filed has been initialized to null within the constructor of the actionForm) - HOWEVER, the field "age" displays "-1" (which is understandable for the same reason).

HOW DO I DO TO GET THE FIELD age (represnting an integer) EMPTY THE FIRST TIME I DISPLAY THE JSP? (rather than the default value as it has been set within the ActionForm constructor???)


I have the same question regarding the tag :
How do I do to set the value of the field to the generic string "-PLEASE SELECT-" (or something like this) the very first time the JSP page is presented to the user (rather than using a valid default value, as it has been initialised within the constructor).


THANKS!

Joey

   <<Less

Re: &lt;html:text&gt; &lt;html:select&gt;, blank fields and "please select" ... How to??

Posted By:   Ziad_Mannan  
Posted On:   Tuesday, July 16, 2002 07:37 AM

Joey


regarding the age field, as far as i know, because the age is an int it will always be initialised to zero even if you dont do that yourself. so if you have to use an int then i dont think there's much you can do. what you can do is use a String instead and then convert that to an int later when you need to. i.e. for the sake of getting the a value for the age field you can make the age field of type String in the FormAction, once the validation has been done and you are about to pass it to your business object to do something with it, you can convert it into an int and pass it on. this can be done in the Action class.


As for the