cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing same function from different Applets

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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();		
}

Former Member
0 Kudos

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.

Former Member
0 Kudos

Yea, I usually just go with one iComand and call loadForm on the Creation event. Using AJAX works fine as well. In fact adobe spry has some widgets built specifically to do this sort of thing. Regarding performance, I haven't come accross a need for 24 drop downs on one page yet

Former Member
0 Kudos

I've seen close to that, unfortunately, but that's only because session variables or any kind of persistence weren't being used.

Kind of - hey, let's make our users select the same 'n' parameters for every report page

Former Member
0 Kudos

Hi Christian,

Thanks a lot

Yeah Ryan Happy this is java script:)

I am closing this thread. But will definitely try with XSL also and get back to you ,experts

Best Regards

Namita

Answers (2)

Answers (2)

Former Member
0 Kudos

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".

Former Member
0 Kudos

Hi Rick,

What is thunking concept

Are you talking of the same concept what Christian has mentioned?

Thanks

Namita

Former Member
0 Kudos

"Thunking" is what you are doing to the browser when it has to load 12 applets

Former Member
0 Kudos

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

Former Member
0 Kudos

Unfortunately, it is not possible to pass arguments in a JavaScript function call from an Applet event.

Mussarat's suggestion will not work.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Thanks Ryan,

But how to set back the element in drop down ?

I could not find this so went for the solution of iBrowser

To be very frank I am blank with XSL

Thanks

Namita

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hi Ankit,

How to generate the tag?

Can you please give step by step solution

After i create my xsl how would then it populate dynamic data from Query in the HTML drop down?

Could you please elaborate little

Thanks

Namita

Former Member
0 Kudos

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.