|
|
Re: How to abort a transformation from a custom tag? [message #30451 is a reply to message #30310] |
Wed, 08 August 2007 12:52 |
Eclipse User |
|
|
|
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 |
Paul Elder 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 |
Eclipse User |
|
|
|
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03675 seconds