Re: AjaxModalContainer/Dialog with JS resources
Re: AjaxModalContainer/Dialog with JS resources
- Subject: Re: AjaxModalContainer/Dialog with JS resources
- From: Chuck Hill <email@hidden>
- Date: Wed, 8 Apr 2009 21:38:02 -0700
On Apr 8, 2009, at 9:31 PM, Greg Hulands wrote:
It behaves the same in that the js files aren't getting loaded.
I tried to force the js into the component with:
public void appendToResponse(WOResponse response, WOContext context) {
super.appendToResponse(response, context);
AjaxUtils.appendScriptHeader(response);
String js = new
String(theApplication().resourceManager().bytesForResourceNamed("js/
bespin/dojo/dojo.js", "app", null));
AjaxUtils.appendScript(context.request(), response, js);
js = new
String(theApplication().resourceManager().bytesForResourceNamed("js/
bespin/bespin/editor/embed.js", "app", null));
AjaxUtils.appendScript(context.request(), response, js);
AjaxUtils.appendScriptFooter(response);
}
But because it goes in after the inline js to get the component
hooked up, it fails.
OK, first off ERXJavaScript is not Ajax technology so you want to
avoid it when doing whizzy Web 2.0 stuff. They really don't play all
that nicely together.
You can inherit from AjaxComponent and implement
addRequiredWebResources something like this:
protected void addRequiredWebResources(WOResponse response) {
ERXResponseRewriter.addScriptResourceInHead(response, context(),
"Ajax", "prototype.js");
ERXResponseRewriter.addStylesheetResourceInHead(response, context(),
"Ajax", "calendar.css");
ERXResponseRewriter.addScriptResourceInHead(response, context(),
"Ajax", "calendar.js");
ERXResponseRewriter.addScriptResourceInHead(response, context(),
"Ajax", "date.js");
}
Or try putting similar code in appendToResponse. Does that work?
I tried doing it before calling super, but it complained that the
session had died.
That seems... odd.
Chuck
On Apr 8, 2009, at 9:20 PM, Chuck Hill wrote:
Any change that AjaxModalDialog would work for you? I am the
guilty party there and can assist. I don't do much with the AMC.
Chuck
On Apr 8, 2009, at 9:08 PM, Greg Hulands wrote:
Hi,
Please forgive all these Ajax problems I'm having - this is my
first demo app using the framework and somethings aren't just
working. I have an AjaxModalContainer that is activated with an
action binding to return the contents. The component that is
returned has some ERXJavascript elements in there to load the js
files for the component. The problem I'm seeing is that those
resources are not getting loaded when the content is being set
into the div. There is also a bit of inline javascript in there
that relies on the js files being loaded that executes, but fails
because the files haven't being loaded.
This happens in both safari and firefox so I'm thinking it is
something in the app.
Any ideas?
Thanks,
Greg
This is the component:
<wo:ERXJavaScript filename="js/bespin/dojo/dojo.js"
framework="app"/>
<wo:ERXJavaScript filename="js/bespin/bespin/editor/embed.js"
framework="app"/>
<div id="editor" style="height:600px; width: 800px;">
<wo:str value = "$probe.script"/>
</div>
<div id="changes">
Greg
</div>
<script type="text/javascript">
var _editorComponent;
function pushToHiddenInput() {
document.getElementById("changes").innerHTML =
_editorComponent.getContent();
}
// Loads and configures the objects that the editor needs
_editorComponent = new bespin.editor.Component('editor', {
language: "php",
loadfromdiv: true,
tabmode: true,
set: {
theme: 'white'
}
});
_editorComponent.onchange(pushToHiddenInput);
_editorComponent.theme = bespin.themes.white;
</script>
This is the generated fragment:
<script _componentName = "pulse.app.components.EditInstrument"
type="text/javascript" src="/cgi-bin/WebObjects/Pulse.woa/_wr_/
wodata=/Users/ghulands/wowodc/trunk/Pulse/build/Pulse.woa/Contents/
WebServerResources/js/bespin/dojo/dojo.js"></script>
<script type="text/javascript" src="/cgi-bin/WebObjects/Pulse.woa/
_wr_/wodata=/Users/ghulands/wowodc/trunk/Pulse/build/Pulse.woa/
Contents/WebServerResources/js/bespin/bespin/editor/embed.js"></
script>
<div id="editor" style="height:600px; width: 800px;">
</div>
<div id="changes">
Greg
</div>
<script type="text/javascript">
var _editorComponent;
function pushToHiddenInput() {
document.getElementById("changes").innerHTML =
_editorComponent.getContent();
}
// Loads and configures the objects that the editor needs
_editorComponent = new bespin.editor.Component('editor', {
language: "php",
loadfromdiv: true,
tabmode: true,
set: {
theme: 'white'
}
});
_editorComponent.onchange(pushToHiddenInput);
_editorComponent.theme = bespin.themes.white;
</script>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden