_Bdot

hi everybody..

i'm creating a gadget which accesses a data base by calling a webservice, and then should display the result into the flyout..

here is my code:

gadget.html

<html>

<head>

<link href="inbox.css" rel="stylesheet" type="text/css" />
<script src="inbox.js" language="JavaScript"></script>

</head>


<script>

System.Gadget.settingsUI = "settings.html";

// init flyout file
System.Gadget.Flyout.file = "flyout.html";


</script>

<body onload="InitializeService()" id="service" style="behavior:url(webservice.htc)" onresult="ShowResult()">

<form name="Form">

<div align="center"><input id="TexteSaisieClient" name="TexteSaisieClient" type="text" SIZE="13" maxlength="60" /></div>
<div align="right"><button onclick="GetText()">Rechercher!</button></div>

</form>

</body>


</html>

we can see that it displays a field where we get a word, or even a letter, and the webservice performs a seek on to the database..

no here is the javascript code:

var iCallID;
var SaisieClient;


function GetText()
{
SaisieClient = document.Form.TexteSaisieClient.value;
iCallID = service.RechService.callService("Operation", SaisieClient);
}

function InitializeService()
{
service.useService("http://localhost/webservicetest/TestBaseVisualFox.asmx wsdl", "RechService");
}


function ShowResult()
{
if((event.result.error)&&(iCallID==event.result.id))
{
var xfaultcode = event.result.errorDetail.code;
var xfaultstring = event.result.errorDetail.string;
var xfaultsoap = event.result.errorDetail.raw;

document.write("il y a une erreur " + xfaultcode +" "+ xfaultstring +" "+ xfaultsoap + " " + event.result.value);
}
else
{

if((!event.result.error) && (iCallID == event.result.id))
{

System.Gadget.Flyout.file = "flyout.html";
System.Gadget.Flyout.show=true;
var flyoutDoc = System.Gadget.Flyout.document;

var reponse = event.result.value;
flyoutDoc.getElementById("txt").innerHTML = reponse; }
else
{
document.write("Il y a une autre erreur!");
}
}

}


the gettext function gets the text typed in by the user and calls the webservice, after having initialized it with the InitialiseService function.

and to finish, the flyout.html code:

<html>
<head>
<title>Inbox - Flyout</title>
<script src="inbox.js" language="javascript" type="text/javascript"></script>
<link type="text/css" rel="stylesheet" href="inbox.css" />
</head>
<body>

resultat:
<div id="txt"></div>

</body>
</html>

So the "txt" item should be changed by the call of the function ShowResult() ...

Why does this stuff doesn't work

thanks for all




Re: Sidebar Gadget Development link between gadget html, anbd flyout html

Andy E

_Bdot wrote:
function ShowResult()
{
if((event.result.error)&&(iCallID==event.result.id))
{
var xfaultcode = event.result.errorDetail.code;
var xfaultstring = event.result.errorDetail.string;
var xfaultsoap = event.result.errorDetail.raw;

document.write("il y a une erreur " + xfaultcode +" "+ xfaultstring +" "+ xfaultsoap + " " + event.result.value);
}
else
{

if((!event.result.error) && (iCallID == event.result.id))
{

System.Gadget.Flyout.file = "flyout.html";
System.Gadget.Flyout.show=true;
var flyoutDoc = System.Gadget.Flyout.document;

var reponse = event.result.value;
flyoutDoc.getElementById("txt").innerHTML = reponse; }
else
{
document.write("Il y a une autre erreur!");
}
}

}



I think the problem is in this block of code. You're showing the Flyout, then immediately trying to set the innerHTML of the "txt" element before the flyout has loaded your page. You're probably best either setting the response text to a global variable, then accessing it from the flyout through the body onload event or setting a timer to set the innerHTML of "txt" after the flyout has loaded.

Andy






Re: Sidebar Gadget Development link between gadget html, anbd flyout html

_Bdot

thanks !

I try it and then i write back if you were right..

Smile






Re: Sidebar Gadget Development link between gadget html, anbd flyout html

_Bdot

I've changed the flyout.html code and now it looks like this:

<html>
<head>
<title>Inbox - Flyout</title>
<script src="inbox.js" language="javascript" type="text/javascript"></script>
<link type="text/css" rel="stylesheet" href="inbox.css" />
</head>
<body onload="FlyOutShowResult()">

resultat:
<div id="txt"></div>

</body>
</html>

and i've added a function to my JS code, also called FlyOutShowResult() which looks like this:

function FlyOutShowResult()
{
var flyoutDoc = System.Gadget.Flyout.document;
var reponse = event.result.value;
flyoutDoc.getElementById("txt").innerHTML = reponse;
}

but it still doesn't work.. maybe i'm a fool..

I don't understand.. i thought i was close to find ..

Crying please help me Smile






Re: Sidebar Gadget Development link between gadget html, anbd flyout html

Andy E

You're closer than you think. Try <body onload="System.Gadget.document.parentWindow.FlyOutShowResult();">

Andy




Re: Sidebar Gadget Development link between gadget html, anbd flyout html

_Bdot

hey andy! fisrt: thanks so much for helping me..

i've tried what you told me but i still doesn't work.. and i've tried so many things.. i still don't understand how Flyouts, and body gadget work.. but if i'm close to find.. i'll keep searching, with your help..

Would you like anything else so that you can help me better

thanks again






Re: Sidebar Gadget Development link between gadget html, anbd flyout html

Andy E

I'm not sure, but it could be how you're referencing your .js file. Are you attaching it to both the flyout file and the main gadget file Why don't you zip up your gadget and send it to me via e-mail so I can get a better look at the code

You can send an email to me here: andy intelligroup eu <-- replace the first space with the @ and the second space with a .

Andy




Re: Sidebar Gadget Development link between gadget html, anbd flyout html

_Bdot

done Smile

the visual effects, and many things are just on the way to be better, but i first pay attention to the functions, and then i'll display it on a better way Smile

ps: i'll mark your help as answer once my gagdet will work






Re: Sidebar Gadget Development link between gadget html, anbd flyout html

_Bdot

Andy.. i miss you Stick out tongue




Re: Sidebar Gadget Development link between gadget html, anbd flyout html

Andy E

Sorry, things got a bit hectic here yesterday after an important telephone call Smile

from what I can see, your problem lies in the function FlyOutShowResult(). You're registering an event which doesn't exist to a variable.

Code Snippet
function FlyOutShowResult()
{
var flyoutDoc = System.Gadget.Flyout.document;
var reponse = event.result.value; <-- this bit here is what's wrong
flyoutDoc.getElementById("txt").innerHTML = reponse;
return(reponse);
}


since you're calling the function from the flyout, the event is "onload" and it doesn't have a result.value. At the top of your javascript, declare the response variable as a global, then with your ShowResult function, add the line var reponse = event.result.value; just above or below the line System.Gadget.Flyout.show. I've done it for you here:

Code Snippet

var iCallID;
var SaisieClient;

var reponse;


function GetText()
{
SaisieClient = document.Form.TexteSaisieClient.value;
iCallID = service.RechService.callService("Operation", SaisieClient);
}

function InitializeService()
{
service.useService("http://localhost/webservicetest/TestBaseVisualFox.asmx wsdl", "RechService");
}


function ShowResult()
{
System.Gadget.Flyout.file = "flyout.html";
if((event.result.error)&&(iCallID==event.result.id))
{
var xfaultcode = event.result.errorDetail.code;
var xfaultstring = event.result.errorDetail.string;
var xfaultsoap = event.result.errorDetail.raw;

document.write("il y a une erreur " + xfaultcode +" "+ xfaultstring +" "+ xfaultsoap + " " + event.result.value);
}
else
{

if((!event.result.error) && (iCallID == event.result.id))
{
var reponse = event.result.value;
System.Gadget.Flyout.show = true;

}
else
{
document.write("Il y a une autre erreur!");
}
}

}

function FlyOutShowResult()
{
var flyoutDoc = System.Gadget.Flyout.document;
flyoutDoc.getElementById("txt").innerHTML = reponse;
return(reponse);
}

That's line 6 to the end of FlyOutShowResult(). It should get it working - although, I have no way of testing your webservice so I can't be sure. Good luck!

Andy






Re: Sidebar Gadget Development link between gadget html, anbd flyout html

_Bdot

thanks so much for your help andy..

Now my gagdet works well, and it wouldn't have been the same without you..

greetings






Re: Sidebar Gadget Development link between gadget html, anbd flyout html

Andy E

Don't mention it, happy to help Smile

Andy