Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » How to abort a transformation from a custom tag?
How to abort a transformation from a custom tag? [message #30274] Thu, 02 August 2007 10:42 Go to next message
Eclipse UserFriend
Originally posted by: technovator.gmail.com

Hi,

Throwing a JET2TagException() does not seem to abort the transformation.
How can we do it?

-- D
Re: How to abort a transformation from a custom tag? [message #30310 is a reply to message #30274] Tue, 07 August 2007 15:31 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
D:

There isn't any explicit abort mechansism. You could try setting a context
variable prior to throwing the JET2TagException:

context.setVariable("abort", Boolean.TRUE);

And then, in you transform, have periodic checks:

<c:if test="not($abort)">
... continue ...
</c:if>

or in iterate tags:

<c:iterate select="yourXPath[not($abort)]" var="...">
... normal processing
</c:iterate>

If you have a suggestion on how JET could do this better, please feel free
to submit a bugzilla:

https://bugs.eclipse.org/bugs/enter_bug.cgi?product=M2T& version=unspecified&component=Jet&rep_platform=PC&am p;op_sys=Windows%20XP&priority=P3&bug_severity=enhan cement&bug_status=NEW&bug_file_loc=http%3A%2F%2F& ;short_desc=&comment=&commentprivacy=0&keywords= &dependson=&blocked=&maketemplate=Remember%20val ues%20as%20bookmarkable%20template&form_name=enter_bug&a mp;assigned_to=m2t.jet-inbox%40eclipse.org

Thanks,

Paul

"D" <technovator@gmail.com> wrote in message
news:6e5b2991842e9b974623e0b942a73677$1@www.eclipse.org...
> Hi,
>
> Throwing a JET2TagException() does not seem to abort the transformation.
> How can we do it?
>
> -- D
>
>
>
Re: How to abort a transformation from a custom tag? [message #30451 is a reply to message #30310] Wed, 08 August 2007 12:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: technovator.gmail.com

Paul Elder wrote:

> There isn't any explicit abort mechansism. You could try setting a context
> variable prior to throwing the JET2TagException:

> context.setVariable("abort", Boolean.TRUE);

Can this be made a standard context variable and checked during Transform?
In that way this can be set either through a custom tag as well as
transform.

-- D
Re: How to abort a transformation from a custom tag? [message #30487 is a reply to message #30451] Wed, 08 August 2007 15:37 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
D:

Well, that certainly would be simple :-). I want to think through a few use
cases before I commit to it though...

We are talking about exposing exceptions, and allowing templates and tags to
react to them. Right now, exceptions are essentially ignored (apart from
logging). At a template level, it seems that one might what to express
something like 'on exception, abort', which would cause the template to stop
evaluating, and the invoking tag (c:include, ws:file, ...) to throw an
exception. That tag could handle the exception, or handling could fall back
to the containing template.

But, I'm reluctant to take a purely exception-handling approach. Often,
execution errors are the result of malformed input. Stopping at the first
error can make it very tedious for a user - we would not appreciate a Java
compiler that quite at the first error. JET already holds all workspace
actions until the main template has completed. Certainly, if we expose
exceptions, one thing we will want to allow control of is whether those
results get written.

Also, an exception handling mechanism should support input validation.
Again, I'd like to somehow support the logging of multiple exceptions, and
then allow the transform author to control whether processing continues.

So, my question to you: What is the specific use case you are working on?

Paul

"D" <technovator@gmail.com> wrote in message
news:651fa01dd57287ac7bc7581f6ebca2ac$1@www.eclipse.org...
>
> Paul Elder wrote:
>
>> There isn't any explicit abort mechansism. You could try setting a
>> context variable prior to throwing the JET2TagException:
>
>> context.setVariable("abort", Boolean.TRUE);
>
> Can this be made a standard context variable and checked during Transform?
> In that way this can be set either through a custom tag as well as
> transform.
>
> -- D
>
Re: How to abort a transformation from a custom tag? [message #30592 is a reply to message #30487] Wed, 08 August 2007 17:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: technovator.gmail.com

Paul:

What I am suggesting is much simpler - a mechanism by which a template
author can abort a transformation. Coming to think of it, may be a custom
tag should only provide a mechanism of reporting an error. And the
template decides what to do with it.

For example, let us assume that ws:file tag returns a status variable and
message in case of failure. Then a template author can write something
like:

<ws:file path="about.html" template="templates/about.html.jet"/>
<c:if test="not($status)">
<c:abort message="Could not write file" extrainfo="${statusMessage}/>
</c:if>

> So, my question to you: What is the specific use case you are working on?

I was hoping you wouldn't ask for this ;-).

What I am trying to do is to use Jet to create java source files from user
input. The user input is going to be from the workbench (i.e UI based) and
there are no input files to be transformed. An example main template file
for creating a singleton pattern will be like this:

<ui:form name="Singleton">
<wsui:project type="select" nature="javaNature"/>
<javaui:package type="select"/>
<ui:text rows="1" cols="80" name="Class Name"/>
</ui:form>

<ws:project name="$singleton.project">
<ws:folder path="src">
<java:package name="$singleton.package">
<java:class name="$singleton.class_name" template="singleton.jet"/>
</java:package>
</ws:folder>
</ws:project>

Basically the first part displays a dialog asking for the information.
wsui:project, javaui:package etc. will provide a combo to select the
project and package. ui:text displaying a text box. Since the user can
select a Cancel from the dialog I need a way of aborting the
transformation.

-- D
Re: How to abort a transformation from a custom tag? [message #33583 is a reply to message #30592] Sun, 09 September 2007 17:37 Go to previous messageGo to next message
Dakshinamurthy Karra is currently offline Dakshinamurthy KarraFriend
Messages: 45
Registered: July 2009
Member
D wrote:

> <ui:form name="Singleton">
> <wsui:project type="select" nature="javaNature"/>
> <javaui:package type="select"/>
> <ui:text rows="1" cols="80" name="Class Name"/>
> </ui:form>

> <ws:project name="$singleton.project">
> <ws:folder path="src">
> <java:package name="$singleton.package">
> <java:class name="$singleton.class_name" template="singleton.jet"/>
> </java:package>
> </ws:folder>
> </ws:project>

Is there any interest in such a tag library? What I have done is mostly
stable and working fine. If there is some interest I can put it up
somewhere (suggestions are welcome).

-- D
Re: How to abort a transformation from a custom tag? [message #33649 is a reply to message #33583] Tue, 11 September 2007 12:19 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
D:

I would certainly be interested in such a contribution. Standard Eclipse
rules would apply:

1) you must have written it yourself, or know all the authors.
2) All the authors and their employers must agree to your submitting it.
3) All the authors and their employers must agree to licensing it under the
Eclipse Public License (EPL).

Paul

"Dakshinamurthy Karra" <dakshinamurthy.karra@gmail.com> wrote in message
news:2ab26ab9b82495158756e08aa050ff53$1@www.eclipse.org...
>D wrote:
>
>> <ui:form name="Singleton">
>> <wsui:project type="select" nature="javaNature"/>
>> <javaui:package type="select"/>
>> <ui:text rows="1" cols="80" name="Class Name"/>
>> </ui:form>
>
>> <ws:project name="$singleton.project">
>> <ws:folder path="src">
>> <java:package name="$singleton.package">
>> <java:class name="$singleton.class_name" template="singleton.jet"/>
>> </java:package>
>> </ws:folder>
>> </ws:project>
>
> Is there any interest in such a tag library? What I have done is mostly
> stable and working fine. If there is some interest I can put it up
> somewhere (suggestions are welcome).
>
> -- D
>
>
>
Previous Topic:Re: JET EXTENSION!
Next Topic:[JET2] Custom XPath to access stereotypes.
Goto Forum:
  


Current Time: Thu Apr 25 06:21:44 GMT 2024

Powered by FUDForum. Page generated in 0.03373 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top