Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem sending info between screens using text boxes

Status
Not open for further replies.

dexter195

Programmer
Jun 18, 2003
220
EU
hi,

im having this problem when i send info from my modifyAdministrator.jsp page to the confirmModifiedInfo.jsp page. the info is stored in beans.

the text boxes are populated with info from a database. the user can then change the info.

im performing checks in the confirm page to see if the info being sent has null values or is an empty string after being trimmed.

my problem occurs when the user deletes the info in the text box. if this is all they do the data originally contained in the text box remains the same when it is sent to the confirm page, it doesnt seem to be changed at all, until the user puts in a space or other text.

i think this is caused because ive given the value of the text box a default value and this will only be changed when its updated rather than deleted.

is there a way around this problem?

here is some of the code:

info being sent
Code:
<TR>
		<TD height="27"><DIV align="left">Forename:</DIV></TD>
		<TD><INPUT type="text" name="forename" VALUE="<%= modAdmin.getForename() %>" > </TD>
	</TR>

checks done on the info
Code:
if ( modAdmin.getForename().trim().equals("") || modAdmin.getForename() == null )
				error.setErrorForename(true);

thanks for the help
 
if ( modAdmin.getForename() == null || modAdmin.getForename().trim().equals(""))
error.setErrorForename(true);
 
cheers prosper,

that did the trick but im slightly confused as to why it worked.

i was under the impression that if it didnt find the first check in the if statement it would move onto the second check, but that wasnt happening in my original code.

thanks for the help
 
In your original code, if modAdmin.getForeName() returned null, then your code would barf on a NullPointerException - so you should always check if the object is null before attempting some operation on that potentially null pointer.

--------------------------------------------------
Free Database Connection Pooling Software
 
makes sence, better change the rest of the if statements accordingly to avoid puking :)

thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top