From: Atkinson, J. (AGRE) <Joh...@sm...> - 2004-04-13 21:21:44
|
First: Thanx Brad, the select works now that I downloaded the nightly= build. Second: I immediately ran into another problem. The next page in the= series basically just propegates the inputs forward "On Load" to another= page through a javascript function that calls location.replace. I wrote a= quick example to show you what happens. Page1.html ------------------------------------------------------- <HTML> <HEAD> <TITLE>TEST PAGE 1</TITLE> </HEAD> <BODY> <FONT SIZE=3D"12" COLOR=3D"red">THIS IS PAGE 1</FONT> <FORM name=3D"Form1" method=3D"GET" action=3D"Page2.html"> <SELECT NAME=3D"select0" > <OPTION VALUE=3D"Zero" SELECTED>0</OPTION> <OPTION VALUE=3D"One">1</OPTION> <OPTION VALUE=3D"Two">2</OPTION> <OPTION VALUE=3D"Three">3</OPTION> <OPTION VALUE=3D"Four">4</OPTION> </SELECT> <BR><BR> <BR> <SCRIPT LANGUAGE=3DJavaScript> function processform() { document.forms[0].action=3D"Page2.html"; var nextElement =3D document.forms[0].elements[0]; if(nextElement.name =3D=3D "select0")=0D { var selection =3D new String(nextElement.value); alert("Selection =3D '" + selection + "'"); }//end of if statement document.forms[0].submit(); }//end of processform function </SCRIPT> </FORM> <A HREF=3D"javascript:processform()">NEXT_PAGE</A> =0D =0D </BODY> </HTML> ------------------------------------------------------- Page2.html ------------------------------------------------------- <HTML> <HEAD> <TITLE>TEST PAGE 2</TITLE> </HEAD> <BODY ONLOAD=3D"javascript:pushforward()"> <FONT SIZE=3D"12" COLOR=3D"red">THIS IS PAGE 2</FONT> <BR><BR> <A HREF=3D"javascript:topage1()">PAGE1</A> =0D <SCRIPT LANGUAGE=3DJavaScript> function pushforward() { location.replace("Page3.html"); }//end of pushforward function function topage1() { window.location=3D'Page1.html'; }//end of topage1 function </SCRIPT> </BODY> </HTML> ------------------------------------------------------- Page3.html ------------------------------------------------------- <HTML> <HEAD> <TITLE>TEST PAGE 3</TITLE> </HEAD> <BODY> <FONT SIZE=3D"12" COLOR=3D"red">THIS IS PAGE 3</FONT> <BR><BR> <A HREF=3D"javascript:topage1()">PAGE1</A> =0D <SCRIPT LANGUAGE=3DJavaScript> function topage1() { window.location=3D'Page1.html'; }//end of topage1 function </SCRIPT> </BODY> </HTML> ------------------------------------------------------- Test.java ------------------------------------------------------- public class Test { ... public void performTest() { try { WebClient webClient =3D new= WebClient(BrowserVersion.INTERNET_EXPLORER_6_0); URL url =3D new URL("http://www.mydomain.com/Page1.html"); HtmlPage page =3D ((HtmlPage) webClient.getPage(url)); savePage(page,"Output_Page1.html"); =0D HtmlAnchor Page2_Link =3D getLinkWithText(page,"NEXT_PAGE"); page =3D ((HtmlPage) Page2_Link.click()); savePage(page,"Output_Page2.html"); }//end of try statement =0D catch(IOException except) { System.out.println("I/O Exception Occurred: " += except.getMessage()); }//end of catch statement }//end of constructor =0D =0D public HtmlAnchor getLinkWithText(HtmlPage page, String text) { java.util.List links =3D page.getAnchors(); for(int i=3D0; i<links.size(); i++) { HtmlAnchor currLink =3D ((HtmlAnchor) links.get(i)); =0D String currLink_Text =3D currLink.asText(); if(currLink_Text.indexOf(text) >=3D 0) { return currLink; }//end of if statement }//end of for loop =0D return null; }//end of getLinkWithText method =0D =0D public void savePage(HtmlPage page, String fileName) throws IOException { File outFile =3D new File(fileName); FileWriter fileOut =3D new FileWriter(outFile); PrintWriter printOut =3D new PrintWriter(fileOut); =0D printOut.print(page.getWebResponse().getContentAsString()); =0D printOut.flush(); fileOut.flush(); printOut.close(); fileOut.close(); }//end of saveResponse method ------------------------------------------------------- What happens is that I get an output of Output_Page1.html and= Output_Page2.html from the test where Output_Page1.html should be the same= as Page1.html and Output_Page2.html should be the same as Page3.html,= however Output_Page2.html is instead the same as Page3.html. Thanks again for the help. Regards, John S. Atkinson ~Smiths Aerospace~ ****************************************** The information contained in, or attached to, this e-mail, may contain= confidential information and is intended solely for the use of the= individual or entity to whom they are addressed and may be subject to= legal privilege. If you have received this e-mail in error you should= notify the sender immediately by reply e-mail, delete the message from= your system and notify your system manager. Please do not copy it for any= purpose, or disclose its contents to any other person. The views or= opinions presented in this e-mail are solely those of the author and do= not necessarily represent those of the company. The recipient should= check this e-mail and any attachments for the presence of viruses. The= company accepts no liability for any damage caused, directly or= indirectly, by any virus transmitted in this email. ****************************************** |