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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Verify Child window from Parent

Status
Not open for further replies.

RMTnut

Technical User
Aug 2, 2002
16
US
I have a child window that I get value from the parent window. However if one text box does not have any value the code stops. Can someone help me out? I am using the follow code to populate the child window.

function onload()
{
thisAppl.AppName.value = opener.document.thisForm.ApplName.value ;
thisAppl.AppMailAddress.value = opener.document.thisForm.ApplMailAddress.value ;
thisAppl.AppHomeCity.value = opener.document.thisForm.ApplMailCity.value;
thisAppl.AppGarageAddress.value = opener.document.thisForm.ApplGarageAddress.value;
thisAppl.AppGarageCity.value = opener.document.thisForm.ApplGarageCity.value;
thisAppl.AppHomePhone.value = opener.document.thisForm.ApplHomePhone.value;
thisAppl.AppWorkPhone.value = opener.document.thisForm.ApplWorkPhone.value;
thisAppl.AppWorkExt.value = opener.document.thisForm.ApplWorkExt.value;
thisAppl.AppEmail.value = opener.document.thisForm.ApplEmail.value;
thisAppl.EffectiveDate.value = opener.document.thisForm.ApplEffDate.value;
}

Thank you
 
wooo - how do you feel, reading such code?

it smells like 'public Membervariables' and 'too.much.nested.Stuff' - Patterns.

Can you refactor it, to do:

thisAppl.AppName.setValues (opener.document.thisForm);

If one of the value-field is empty, you probably get a NullPointerException. You may catch it, and return an empty String ("") instead.


seeking a job as java-programmer in Berlin:
 
Thank you for the quick response, I am not sure how to go about implementing your suggestion. I understand the logic but not sure how to make the change.
 
Yes - I made a mistake.
It could be like this:

Code:
thisAppl.setValues (opener.document.thisForm);

// and in the thisAppl-Class:
setValues (? form)
{
	AppName.value 		= form.getAppName ();
	AppMailAddress.value	= form.getAppMailAddress();
	// and so on
}

// and in the opener.document.thisForm -Class
public String getApplName ()
{
	// assuming AppName is in a TextField tfAppName
	// here we avoid a NullPointer
	if (tfAppName.getText () == null) return "";
	else return tfAppName.getText ();
}
...which is far from being elegant, but more can't be done, without knowing all the code.


seeking a job as java-programmer in Berlin:
 
The function onload() is all the code that I have so far. The function is located on a child window with the form name of thisAppl. I am trying to get text value from the parent window which form name is thisForm. I am sorry if I sound dumb but I am lucky to get this far. Am I way off base and should start all over?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top