File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes populating value in formbean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "populating value in formbean" Watch "populating value in formbean" New topic
Author

populating value in formbean

Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 236
hi guys
iam trying to populate values from jsp to a formbean when i submit the form
every thing works fine
but if didnt fill the data for a text box the corresponding property in formbean is populated with empty sting("") eventhough i initialized the property with statement like below
private String searchString=null; but for other properties if i didnt enter any value null is populating

looking for your replies
amir
Laxmikant Ruikar
Greenhorn

Joined: Nov 29, 2005
Posts: 23
Form bean values are populated as per request parameter values. If its textbox then its request parameter value is "". So its not a null value.


LDR
Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 236
this is my jsp code for that searchstring iam not using value attribute


<html:text property="searchString" style="width: 300px;" />
chandra mohan
Greenhorn

Joined: May 05, 2008
Posts: 20
check the value present in the html source code
Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 236
yes chandru you are right

<input type="text" name="searchString" value="" style="width: 300px;">

but i didnt added this value attribute in my jsp but if i saw the view source
it was added thier

any workaround for this
chandra mohan
Greenhorn

Joined: May 05, 2008
Posts: 20
Why should you need a null to be returned ?
What ever the condition you are checking you can check for "" instead of null.
Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 236
i want to know because of any mistake insted of null empty string("") is populated
chandra mohan
Greenhorn

Joined: May 05, 2008
Posts: 20
I think by default it will give only "" for string .

You said you are getting null value for other fields what's the data type for those fields?
 
 
subject: populating value in formbean