on 07-30-2008 1:07 PM
Hi All,
I have 12 iBrowser as Defect Reason and another 12 iBrowser as Defect Code
selection event on Defect Reason iBrowser should set code in Defect Code iBrowser
I want to call one common function for all the 12 applets but how can i pass applet name ?
example
<APPLET NAME="DefectReasonBrowserSh1" WIDTH="130" HEIGHT="60" CODE="iBrowser" CODEBASE="/XMII/Classes" ARCHIVE="illum8.zip" MAYSCRIPT>
<PARAM NAME="QueryTemplate" VALUE="A/SlittingDefectQuery">
<PARAM NAME="DisplayTemplate" VALUE="A/SlittingDefectReasonBrowser">
<param NAME="SelectionEvent" VALUE="countNumber">
</APPLET>
<APPLET NAME="DefectReasonBrowserSh2" WIDTH="130" HEIGHT="60" CODE="iBrowser" CODEBASE="/XMII/Classes" ARCHIVE="illum8.zip" MAYSCRIPT>
<PARAM NAME="QueryTemplate" VALUE="A/SlittingDefectQuery">
<PARAM NAME="DisplayTemplate" VALUE="A/SlittingDefectReasonBrowser">
<param NAME="SelectionEvent" VALUE="countNumber">
</APPLET>
Both the applets are same only the name of the applet varies and both of them call the same function
Problem is how could one know which Applet is selected if one have to access the method
"document.appletname.getQueryObject"
How can applet name be passed dynamically for the function countNumber
Thanks
Namita
Heres what I do for drop downs.
var GET_LIST_ONE_QUERY ='QUERIES/GET_LIST_ONE_QUERY';
var GET_LIST_TWO_QUERY ='QUERIES/GET_LIST_TWO_QUERY';
function getCommandObject(TEMPLATENAME, SERVER){
document.CommandApplet.setQueryTemplate(TEMPLATENAME);
document.CommandApplet.getQueryObject().setServer(SERVER);
return document.CommandApplet;
}
function getDBServer(){
return document.MainForm.DB_SERVER.value;
}
function getXacuteServer(){
return 'XacuteConnector';
}
function GetList_One()
{
var boxList_One = document.MainForm.List_One;
boxList_One .options.length = 0;
var commandObject = getCommandObject(GET_LIST_ONE_QUERY,getDBServer());
var commandObjectQuery = commandObject.getQueryObject();
if (commandObject.executeCommand())
{
boxList_One.options[0] = new Option("ALL","%");
for(i=1;i<=commandObject.getRowCount();i++)
{
boxList_One.options<i> = new Option(commandObject.getValue(1, i),commandObject.getValue(2, i));
}
}
GetList_Two();
}
function GetList_Two()
{
var i=document.MainForm.List_One.selectedIndex;
var List_One =document.MainForm.List_One.options<i>.value;
var List_Two = document.MainForm.List_Two;
List_Two.options.length = 0;
var commandObject = getCommandObject(GET_LIST_TWO_QUERY,getDBServer());
var commandObjectQuery = commandObject.getQueryObject();
commandObjectQuery.setParam(1,List_One);
if (commandObject.executeCommand())
{
List_Two.options[0] = new Option("ALL","%");
for(i=1;i<=commandObject.getRowCount();i++)
{ List_Two.options<i> = new Option(commandObject.getValue(1, i),commandObject.getValue(2, i));
}
}
}
function loadForm(){
GetList_One();
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's JavaScript happy
That will work; hopefully you are calling the "loadForm" function on the CreationEvent of the applet, not the onload event of the body element.
With this approach, you are delivering the data from the server into the iCommand, and then building the drop down elements after the fact. It works, but probably as not as efficient as having it delivered straight from the server.
AJAX?
I wonder if there is a way to eliminate the 12 drop downs (or lessen the number) via session properties or URL parameters.
It was interesting to see the various approaches recommended here - particularly since some of them don't work!
The best approach with MII, in terms of allowing multiple applets to utilize a single handler, is to use the "thunking" concept. In this case, a very small handler is created that invokes the "shared" function, passing a reference to the specific applet as its parameter.
Thus, for your 12 reject code browsers, you'd create 12 very simple handlers each with a unique name, then have each invoke the shared handler as in:
mainHandler(document.rejectCodeBrowser1)
...or...
mainHandler(document.rejectCodeBrowser2)
This same technique can be used for those who prefer to code their HTML scripting in VBScript instead of JavaScript. You'll always need to have a "parameterless": JavaScript function as the primary target for an MII applet event handler, but you can then call another function written in VBScript (or whatever) from within that "stub".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Namitha,
Create an input parameter for your function countnumber viz countnumber(appletname), And hardcode the applet name while calling the function.
e.g.
<APPLET NAME="DefectReasonBrowserSh1" WIDTH="130" HEIGHT="60" CODE="iBrowser" CODEBASE="/XMII/Classes" ARCHIVE="illum8.zip" MAYSCRIPT>
<PARAM NAME="QueryTemplate" VALUE="A/SlittingDefectQuery">
<PARAM NAME="DisplayTemplate" VALUE="A/SlittingDefectReasonBrowser">
<param NAME="SelectionEvent" VALUE="countNumber("DefectReasonBrowserSh1")">
</APPLET>
<APPLET NAME="DefectReasonBrowserSh2" WIDTH="130" HEIGHT="60" CODE="iBrowser" CODEBASE="/XMII/Classes" ARCHIVE="illum8.zip" MAYSCRIPT>
<PARAM NAME="QueryTemplate" VALUE="A/SlittingDefectQuery">
<PARAM NAME="DisplayTemplate" VALUE="A/SlittingDefectReasonBrowser">
<param NAME="SelectionEvent" VALUE="countNumber("DefectReasonBrowserSh2")">
</APPLET>
Then you can access each applet by using javascript's eval function in your function countNumber
eval("document."+appletName+".getQueryObject()");
Hope that helps you.
Regards,
Musarrat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Having 12 or 24 applets on a page is lot! You may want to instead create an XSL that takes the query result and dynamically creates an HTML drop down (instead of an iBrowser). With this you can easily pass an argument in the JavaScript function using the SELECT's element onchange event. It will speed up the page load and won't have the overhead of all those applets on the page.
Namita,
Did you try "this" keyword in your javascript method? It should return you the current applet object. You can then use - this.getQueryObject().
For such a large number of applets, you could use <servlet> tag for generating dynamic html drop downs (close to what Ryan suggested). The only thing to be kept in mind is that if you are using Datalinks in your iBrowser and you don't want to show datalink values in your drop-down, you might not be able to do that with the default options. For that you might have to write your own XSLT to generate the HTML drop-down, having datalink values though not showing them on UI.
Regards,
Ankit Jain
Hi Ankit,
Thanks for the suggestion but where should i mention this .getQueryObject
<param name = SelectonEvent" value=(this.QueryObject)>
this is what you are saying
The biggest problem in HTML Drop Down is i cannot set the value
I can get the selected value but how to set the required value in HTML Drop Down
Is there any help available for XSL i could not understand how to create customized xsl and then pop up in HTML drop down
I always go wrong with XSL
Could you elaborate in detail
Thanks
Namita
Namita,
this.getQueryObject() should be used in your javascript function that you call from the <param> tag of the applet.
i.e.
<param name = "SelectonEvent" value="functionName">
and in javascript you can use -
function functionName()
{
var qryObj = this.getQueryObject();
// rest of the code.
}
for selecting a value you might have to create the <select> tag at runtime in your javascript.
If I understand your requirement correctly, you select an option from the dropdown and the other dropdown should get populated.
If so, for the first dropdown use <servlet> tag to generate the drop-down, and on "onChange" event of it call a javascript function which would first execute a command applet to get the resultset against the selected option. Then you can generate the <select> tag dynamically to display the second dropdown. Or you can even have the second dropdown as an iBrowser which would get reloaded when you make a selection from your first drop-down.
In this case you might not have to write a custom XSL at all.
Use the syntax given below for replacing your applet with <servlet> tag -
<SERVLET NAME="Illuminator">
<PARAM NAME="QueryTemplate" VALUE="Demo/Misc/LocationListQuery">
<PARAM NAME="StyleSheet" VALUE="http://localhost/Illuminator/StyleSheets/IllumRowsetSelect.xsl">
<PARAM NAME="Content-Type" VALUE="text/xml">
<PARAM NAME="SelectName" VALUE="MySelect">
<PARAM NAME="onChange" VALUE="yourJavaScriptFunction">
</SERVLET>
Just to know what all parameters you can pass from the <PARAM> tag go to <MII_Installation_drive>/Inetpub/wwwroot/Illuminator/StyleSheets/IllumRowsetSelect.xsl.
There at the top you can see some <xsl:param> tags, all the variables refered in these tags as "name" attribute can be passed as a parameter from the <servlet> tag above.
You will find other MII provided default xsl stylesheets in the same folder, which would suffice your basic requirements.
Now lets get back to your case. Now as I said instead of first applet use this servlet tag so that you can get the dropdown to select from. Once you select any option, the function name called on "onChange" param would get called in your javascript.
On the call of this function you can pass the selected value from drop down to the iBrowser query object of your second applet and refresh the same. Doing so, would now populate your 2nd iBrowser applet with the required options only in the drop down.
There could be one issue, that your user interface might not be consistent. i.e. somewhere you would see html drop-downs (i.e. <select> tags) and somewhere iBrowser applets.
As a remedy, my other solution that you can generate the <select> tag dynamically, so that every drop-down is an html element.
For this, in your javascript function called from the <servlet> tag above, you can have an iCommand applet executed, where you would be passing the selected value as a parameter. And then, for every value retrieved, you can create an <option> tag for your <select> tag. ([Click here|http://www.javascriptkit.com/jsref/select.shtml] for details on creating <option> tags dynamically).
Let me know if it was helpful.
Regards,
Ankit Jain.
User | Count |
---|---|
11 | |
6 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.