![]()
Unifying the Java and Javascript Tribes
under a Clarion NationHave you wanted your users to use your web application without the Java download wait,
but ...
you still wanted to have Java functionality in other procedures of the same application? A real pain, right? Until now!Here is an explanation of the major functions of the example:
![]()
BIG, HUGE DISCLAIMER: This is not a product, it is just an experiment.
It is not totally debugged and I have not explored all of the angles.
If you benefit from the concepts and ideas below, great, if not, you have been warned there is risk on your part. So proceed with caution!
Speaking of which:Caution: Please review all of the following steps first before making changes. Next save all files that will be affected by these changes to another directory. Then make the changes.
Java by procedure (or not)
This requires using Tony Goldstein's instructions at the CWSuperpage
However, you should make one change in his instructions. Put this code from step 3#BOXED ('Java')
#PROMPT ('Use Caffeine-Free WebWindows', CHECK), %AppCaffeineFree, AT(10)
#ENDright after this code in the Internet Connect template
#BOXED ('General')
#PROMPT ('Return if launched from browser', CHECK), %WinDisableFromBrowser,AT(10)
#END
#ENDJust perform a Search on 'Return if launched from browser' using Alt-F3 to find the above code.
OnClick Event Handler Example (Non-Java)
This requires the following code as seen below. You will need to create a button as shown above (the Select-N-Go button). Then go to the Internet Connect procedure template and click on the Individual Override for your button. Next click on the HTML tab and add the HTML code as shown below. Be sure to check the"Remove default HTML generation checkbox.
![]()
Now you are going to need OnClick Event code or you will get an error in your browser. I used this code below:
jsstring='<<SCRIPT>' &|
'function getListValue(list)' &|
'{{' &|
'var listValue = "";' &|
'if (list.selectedIndex != -1) {{' &|
'listValue = list.options[list.selectedIndex].text;' &|
'}' &|
'window.open(''http://''+listValue+'''',''myPage''' &|
',''width=''+screen.width+'',height=''+screen.height+'',top=0,left=0'');' &|
'}' &|
'<</SCRIPT>'target.writeln(clip(jsstring))
The variable jsstring is a local variable - jsstring STRING(1000)
I put all of this code in the Internet Embed, After Generating HTML Code embed of the "Welcome to Select-N-Go (Non-Java)" string control. Now there is OnClick event code for HTML page.OnSubmit Event Handler Example (Non-Java)
The OnSubmit Event requires some modifications of the template and OOP code but not much. The following modifications assume you have already made the Caffiene-Free modifications using Tony Goldstein's instructions at CWSuperpageThe following two steps affect HTMLClass in files ICHTML.INC and ICHTML.CLW
Step 1
Add this code to ICHTML.INCWriteFormHeaderOnSubmitHandler PROCEDURE(<STRING>)
Step 2
Add this code to ICHTML.CLW (put on the last line)HtmlClass.WriteFormHeaderOnSubmitHandler PROCEDURE(<STRING attr>)
CODE
SELF.Writeln('<<FORM NAME="ClarionForm" METHOD=GET ACTION="' & SELF.Files.GetProgramRef() & '" ' & attr & ' onSubmit="OnSubmitHandler()">')Step 3
This step requires you make this adjustment to Step 1 of Tony Goldstein's Caffiene-Free code in the WebWindowClass.CreatePageHeader method in ICWINDOW.CLWChange:
IF (SELF.AllowJava)
Target.WriteFormHeader()
ELSE
Target.WriteFormHeaderNoJava()
ENDTo:
IF (SELF.AllowJava)=FALSE
IF (SELF.AllowOnSubmitHandler)=true
Target.WriteFormHeaderOnSubmitHandler()
ELSE
Target.WriteFormHeaderNoJava()
END
ENDThat's it. Save everything and check it out.
PageUp Button
This code goes in the accept embed
brw2.takescroll(Event:pageup)PageDown Button
This code goes in the accept embed
brw2.takescroll(Event:pagedown)BIG TIP: Be sure you override the list box with WebHTMLListClass or else no HTML list box if you are need a non-Java app with a list box .
Mike Pasley
Team Topspeed - Internet Connect
Questions? Comments?
Email MikePasley at mpasley@logicentral.com