Thank you both for your prompt responses. The information provided has
definitely helped.
I have the old-style injection working with a declared argument
@GET
public Object doGet() {
return getView("index").arg("group", group);
}
But I haven't got the method based injection working (so I can use
${This.getGroup()}). I have no doubt I am missing something. The error I
see is below,
<snip>
Caused by: freemarker.core.InvalidReferenceException: Expression
This.getMoreStuff is undefined on line 59, column 48 in
file:/C:/nuxeo/NuxeoEP5_DEMO/NuxeoServer/server/default/data/NXRuntime/web/modules/ca.metalogic.edprototype/skin/views/Document/index.ftl.
at
freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
at
freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:134)
at
freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:114)
at
freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
<snip>
Now, I have noticed that the generated web-types file appears to be
missing the type information. Is this a separate or related issue?
ca.metalogic.edprototype.ChallengeWebObject|org.nuxeo.ecm.webengine.model.WebObject
ca.metalogic.edprototype.Main|org.nuxeo.ecm.webengine.model.WebObject
My ftl reference is simple enough >> ${This.getMoreStuff()}
And the java method is simple as well
public String getMoreStuff() {
String thestuff = "This is more stuff";
return thestuff;
}
Thanks,
Bruce.
Bogdan Stefanescu <[email protected]>
08/27/2009 04:45 AM
To
Radu Ux D. <[email protected]>
cc
[email protected], Bruce Grant <[email protected]>
Subject
Re: [Ecm] Webengine Documentation
There is the complete list of built-in variables: (you can look in
AbstractWebContext to see what is injected by default)
Context - the webengine context. you can use this to access any contextual
data like the http request, response, traversed objects etc
Module - the current webengine module (you can use this to find files in
your module etc)
Engine - the engine (a singleton object)
basePath - base path of the request
skinPath - the skin path (a prefix) to be used to create links to static
resources
Root - the root object (the first object in the chain matched by the
request)
This - the current (or target) object (e.g. the object which is
rendered)
Document - the current document if the current object is a document
wrapper otherwise null
Adapter - the current (target) adapter if the target object is an adapter
otherwise null
Session - the repository session if you have a repository otherwise null.
Note that you can also inject your own variables when rendering a
template. See for example:
See for example the object Group.java in admin module:
@GET
public Object doGet() {
return getView("index").arg("group", group);
}
here ${group} is injected into the rendering context. You can do this when
you want to expose custom variables but anyway the recommended way is to
expose these objects through the ${This} variable.
Example: you create a method
public String getGroup() {
return group;
}
on the target object and in the template you access the group like this:
${This.group} or ${This.getGroup()}
This is better since you don't hard-code variable names in java cod and
also variables that need computations are lazy computed - only when the
method is called from the template and not before the template is
rendered.
Bogdan
On 27 août 09, at 09:42, Radu Ux D. wrote:
Hi
Do you refer to ActionFragments and Models (like contextualLinks model and
its action fragment)? If so, you can check
http://www.nuxeo.org/xwiki/bin/view/FAQ/DevelopWebEngineModule/. Also,
look for theme-service (
http://doc.nuxeo.org/5.1/books/nuxeo-book/html-single/#theme-service)
And of course, the Javadoc (I think webengine-sites can provide you with
"how to do" example and also explains how the things works.)
If you need more info, please point what specifically do you think you
miss.
Thx, Radu
Bruce Grant wrote:
I have spent the last week digging through samples, wiki/blog, and all
existing documentation. It's been a challenge because the documentation is
spread out in various areas and some seems out of date. Is there a
definitive (internal?) document that spells out all of the variables and
options available at rendering time? What are the limitations on their
use?
In one of the samples that documentation above explains the following
variables are available:
Context - the WebContext instance
Engine - the WebEngine instance
This - the target Web Object.
Root - the root WebObject.
Document - the target Document if any otherwise null.
Session - the Repository Session. (aka Core Session)
basePath - the request base path (context path + servlet path)
But it's apparent from the more recent Wiki/Blog app that other options
are available from within the freemarker template (e.g., API). Are these
options and capabilities enumerated and explained in any documentation?
Thank you,
Bruce.
------------------------------------------------------------------------
_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm
To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm
_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm
To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm
_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm
To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm
_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm
To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm