Skip to main content

adding new jMaki widget clobbers the rest of the page

2 replies [Last post]
bbissett
Offline
Joined: 2003-06-16

I wanted to try a simple "hello world" jMaki widget of my own, and when I add it to the web page all my other content disappears. The body of my JSP is:

-----
<p>Other text.</p>

<a:widget name="mytest"/>
-----

And in my resources directory I have a "mytest" folder with component.html:

<div id="${uuid}"></div>

...and component.js:

jmaki.namespace("jmaki.widgets.mytest");

jmaki.widgets.mytest.Widget = function(wargs) {

var _widget = this;
var uuid = wargs.uuid;

document.write("hello world");
}

When I view the page, I see "hello world" but I don't see "Other text." I guess there is something fundamental that I'm missing, but I can't figure out so far what is missing (e.g., something in the javascript, a lifecycle event, maybe the div is overwriting the "other text" paragraph). Please let me know what I need to change to be able to display my own jMaki widgets in a web page.

Thanks,
Bobby

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
carlavmott
Offline
Joined: 2005-02-10

Hi Bobby,

Your mostly there but need to do the following in your component.js

jmaki.namespace("jmaki.widgets.mytest");

jmaki.widgets.mytest.Widget = function(wargs) {

var container = document.getElementById(wargs.uuid);
container.innerHTML = "hello world";
}

the document.write is what is causing the problem. You only want to update the div you created for this widget.

Carla

bbissett
Offline
Joined: 2003-06-16

> the document.write is what is causing the problem.
> You only want to update the div you created for this
> widget.

Thank you! That makes perfect sense, and has helped the jMaki conceptual model snap into my head much better. I forgot how this all works once I got to the "what should I put in for javascript?" stage. See what you get for hiding all the JS from Java developers like me? (Heh heh.)

Cheers,
Bobby