Discussion:
[Middlegen-user] ${delegate} in generated Struts Action subclasses
Davorin Kremenjas
2004-10-17 19:31:09 UTC
Permalink
Hello everyone.
This is a newbie question so be patient, please.

I'm trying to set up a small MVC web app using Middlegen as a source code
generator for
Hibernate as Model, Struts as Controller and JSP as View.
I know that Struts plugin for Middlegen is in alpha state but since it does
all the
tedious work I decided to give it a try.
After generating Struts and Hibernate code (which works jst fine) I'm trying
to run
webdoclet task as mandated by Middlegen documentation for Struts plugin.
Here is where I get into errors.
In every Java file that extends Struts Action class there is a line with a
token ${delegate}.
Of course, files cannot be compiled and run so everything becomes useless.
This is how the webdoclet task looks like:

<target name="webdoclet" >
<mkdir dir="${build.web-meta.dir}"/>
<taskdef
name="webdoclet"
classname="xdoclet.modules.web.WebDocletTask"
classpathref="lib.class.path"/>
<webdoclet
destdir="${build.web-meta.dir}/WEB-INF"
excludedtags="@version,@author">
<fileset dir="${build.gen-src.dir}">
<include name="**/web/**/*.java" />
</fileset>
<deploymentdescriptor
servletspec="2.3"
validatexml="true"
mergedir="${basedir}/src/xdoclet"/>
<strutsconfigxml
destdir="${build.web-meta.dir}/WEB-INF">
<configParam name="version" value="1.2"/>
</strutsconfigxml>
</webdoclet>
</target>

And this is an error that it produces for every Action subclass:

[webdoclet] Error parsing File
E:\HIBERNATE\apps\...\web\struts\ViewTvarAction.java:
Encountered "{" at line 65, column 25.
[webdoclet] Was expecting one of:
[webdoclet] "instanceof" ...
[webdoclet] ";" ...
[webdoclet] "=" ...
...

Aforementioned "{" is the begining brace of ${delegate} token.
The token comes in five variations:

${delegate}.remove(xxxForm);
xxxForm = ${delegate}.edit(xxxForm);
xxxForm = ${delegate}.create(xxxForm);
List xxxs = ${delegate}.select(xxxForm);
xxxForm = ${delegate}.update(xxxForm);

OK, it's obvious there should be an object reference instead of a token.
What I don't know is
which object.

Am I missing a point here? Is there another step I forgot to take?
I'm ready to edit all corresponding lines by hand but I don't have a clue
what should
I put instead of ${delegate}...

Thanks everyone.
Eivind Waaler
2004-10-17 19:39:01 UTC
Permalink
In the latest version of Middlegen, the Struts plugin is dependent on the
adapter plugin. See the samples/build.xml. You need the <adapter> subtask
for the <middlegen> task.

Look at the sample and see if you figure out.

.eivind
Post by Davorin Kremenjas
Hello everyone.
This is a newbie question so be patient, please.
I'm trying to set up a small MVC web app using Middlegen as a source code
generator for
Hibernate as Model, Struts as Controller and JSP as View.
I know that Struts plugin for Middlegen is in alpha state but since it does
all the
tedious work I decided to give it a try.
After generating Struts and Hibernate code (which works jst fine) I'm trying
to run
webdoclet task as mandated by Middlegen documentation for Struts plugin.
Here is where I get into errors.
In every Java file that extends Struts Action class there is a line with a
token ${delegate}.
Of course, files cannot be compiled and run so everything becomes useless.
<target name="webdoclet" >
<mkdir dir="${build.web-meta.dir}"/>
<taskdef
name="webdoclet"
classname="xdoclet.modules.web.WebDocletTask"
classpathref="lib.class.path"/>
<webdoclet
destdir="${build.web-meta.dir}/WEB-INF"
<fileset dir="${build.gen-src.dir}">
<include name="**/web/**/*.java" />
</fileset>
<deploymentdescriptor
servletspec="2.3"
validatexml="true"
mergedir="${basedir}/src/xdoclet"/>
<strutsconfigxml
destdir="${build.web-meta.dir}/WEB-INF">
<configParam name="version" value="1.2"/>
</strutsconfigxml>
</webdoclet>
</target>
[webdoclet] Error parsing File
Encountered "{" at line 65, column 25.
[webdoclet] "instanceof" ...
[webdoclet] ";" ...
[webdoclet] "=" ...
...
Aforementioned "{" is the begining brace of ${delegate} token.
${delegate}.remove(xxxForm);
xxxForm = ${delegate}.edit(xxxForm);
xxxForm = ${delegate}.create(xxxForm);
List xxxs = ${delegate}.select(xxxForm);
xxxForm = ${delegate}.update(xxxForm);
OK, it's obvious there should be an object reference instead of a token.
What I don't know is
which object.
Am I missing a point here? Is there another step I forgot to take?
I'm ready to edit all corresponding lines by hand but I don't have a clue
what should
I put instead of ${delegate}...
Thanks everyone.
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Davorin Kremenjas
2004-10-18 10:58:06 UTC
Permalink
Thanks.
I'll build with adapter plugin included and see what happens.

Loading...