Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "MoDisco/Components/JSP/Documentation/0.9"

< MoDisco‎ | Components‎ | JSP
(JSP Generation)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{MoDiscoTabs|JSP|{{MoDiscoTab|JSP|Documentation|0.9}}{{MoDiscoTab|JSP|Architecture|0.9}}}}
+
#REDIRECT&nbsp;[[MoDisco/Moved To Help Center]]
==JSP Metamodel==
+
 
+
The Modisco JSP MetaModel inherits from the Modisco XML one :
+
 
+
[[Image:JSP_Metamodel.png]]
+
 
+
 
+
The choice to extend the XML metamodel was made because JSP scripts use the same tag mechanism, attributes and comments, and contain well formed XML most of the time.
+
 
+
According to the "Java Server Pages Specifications Version 1.2", JSP content is divided into 4 categories :
+
*JSP Scripts :
+
**JSP Scriplet : <code>  <% int variable = 0;%> </code>
+
**JSP Expression : <code><nowiki> <%= variable %> </nowiki> </code>
+
**JSP Declaration :<code><nowiki> <%! int variable = 0; %> </nowiki> </code>
+
*JSP Actions : <code><nowiki> <myPrefix:myAction arg1="value" /> </nowiki> </code>
+
**JSP Standard Action : <code><nowiki>  <jsp:getProperty name="beanName" property="propertyNamef" /> </nowiki> </code>
+
*JSP Directive :  <code><nowiki> <%@ include file="myFilePath" %> </nowiki> </code>
+
**JSP TagLib : <code><nowiki> <%@ taglib prefix="myPrefix" uri="taglib/mytag.tld" %> </nowiki> </code>
+
*Comments : <code><nowiki>  <%-- This is a JSP comment --%>  </nowiki> </code>
+
 
+
==JSP Discoverer==
+
 
+
===User Manual===
+
The plug-in provides the user with a contextual menu to easily create JSP models.
+
 
+
By right-clicking on a JSP Project in the Eclipse '''Package Explorer''' view and choosing '''Discovery > Discoverers > Discover JSP Model...''', you can quickly create the JSP model of your application:
+
 
+
[[Image:MoDisco_DiscoverJSP_menu.png|frame|center|Menu in Eclipse to create a JSP model from a Java project]]
+
 
+
You can also select one or several files to create a model for each one of them:
+
 
+
[[Image:MoDisco_SeveralJSP_Menu.png|frame|center|Menu in Eclipse to create a JSP model from several JSP files]]
+
 
+
A discovery parameters dialog opens to let you specify the parameters of the discovery:
+
 
+
[[Image:MoDisco_Launching_discovery_org.eclipse.modisco.jee.jsp.discoverer.resource.png|frame|center|JSP discoverer parameters dialog]]
+
 
+
* Set '''SERIALIZE_TARGET''' to true if you want to save the model to a file
+
* You can define '''TARGET_URI''' to the location of a file in your workspace. If it is not defined and SERIALIZE_TARGET is true, a model file will be created in the project.<br>'''Beware: the file will be overwritten if it already exists!'''
+
 
+
Once launched, a progress dialog will appear as soon as the operation begins. Depending on the size of your application, the reverse engineering process might take some time to complete:
+
 
+
[[Image:MoDisco_discoverer_org.eclipse.modisco.jee.jsp.discoverer.javaElement_in_progress.png|frame|center|Progress dialog during model creation]]
+
 
+
At the end of the process, the newly created model file is added to the root of your project if you set SERIALIZE_TARGET to true:
+
 
+
[[Image:MoDisco_JSP_ModelInWorkspace.png|frame|center|JSP model in the Package Explorer]]
+
 
+
And the model is opened in the default model browser if you selected '''Open model in editor after discovery''':
+
 
+
[[Image:MoDisco_JSP_inModelBrowser.png|frame|center|JSP model in MoDisco model browser]]
+
 
+
The JSP XMI files (with a filename ending in "_jsp.xmi" by convention) can be opened in any model browser:
+
 
+
[[Image:MoDisco_JSP_OpenWith.png|frame|center|Opening a JSP model]]
+
 
+
===Discovery Limitations===
+
Because the JSP language is used to generate some content, JSP constructs can be placed almost anywhere in the file, which implies some limitations.
+
 
+
This is why the "isTagFragment : EBoolean" attribute was added. In fact, everything contained in a tag declaration, as in its body, is considered as a children of this tag. It is indeed necessary to be able to differentiate whether the JSP tag is used to generate the tag description, or its body.
+
 
+
Some ways of implementing JSP might cause some problems with the parser, especially for the evaluation of tag attributes. What was expected to be found is some kind of syntax like :
+
 
+
<code> name="value" </code> or <code> name='value' </code> or even <code> name=value </code>
+
 
+
Sometimes we were faced with implementations like :
+
<code><nowiki> <tag name=" <% if(condition){ %>  value1" <% }else{ %>  value2" <% } %> > </nowiki> </code>
+
 
+
The parser finds the opening double quote for the attribute's value, then looks for the closing one.
+
 
+
The returned value will be:
+
 
+
[[Image:JSP_Metamodel_Limit_1.png]]
+
 
+
with an exception raised on the last double quote, because '=' is expected.
+
 
+
===Source Repository===
+
 
+
All of the source code is stored in a public source repository, which you can access at:
+
 
+
[https://dev.eclipse.org/svnroot/modeling/org.eclipse.gmt.modisco/plugins/trunk/org.eclipse.gmt.modisco.jee.jsp.discoverer/ https://dev.eclipse.org/svnroot/modeling/org.eclipse.gmt.modisco/plugins/trunk/org.eclipse.gmt.modisco.jee.jsp.discoverer/]
+
 
+
===Discoverer API===
+
 
+
Each MoDisco discoverer responds to a normalized interface and can be called programmatically (see org.eclipse.gmt.modisco.infra.discoverymanager.Discoverer).
+
 
+
As an example, you may checkout the code from org.eclipse.gmt.modisco.jsp.discoverer.tests project.
+
 
+
== JSP Generation ==
+
 
+
The goal of the JSP Generation plug-in is to allow JSP/Html code generation from a Java model
+
 
+
=== Description ===
+
 
+
 
+
[[Image:JspM2T.PNG|JSP Code Generation|frame|center]]
+
 
+
This plug-in proposes [[Acceleo|Acceleo MTL]] modules for generating JSP/html files conforming to JSP models. There is only one template which generates the code.
+
 
+
JSP models are obtained with the [[#JSP_Discoverer|JSP Discoverer]] component.
+
 
+
=== User Manual ===
+
 
+
First, you need a JSP model. Please refer to the JSP Discoverer user manual.
+
 
+
To launch a JSP generation:
+
 
+
*Checkout ''org.eclipse.modisco.jee.jsp.generation'' into your workspace from the Eclipse SVN repository, and create an Accelo launch configuration pointing to the ''GenerateJsp'' java class, and specify the input model and target folder.
+
 
+
Or
+
 
+
*Add ''org.eclipse.modisco.jee.jsp.generation'' to your plug-in dependencies and use the ''GenerateJsp'' main method with the input model and target folder as parameters. The code should look like this :
+
<source lang="java">
+
GenerateJsp jspGenerator = new GenerateJsp(URI.createFileURI("C:/.../my.javaxmi"),
+
    new File("C:/.../myOutputFolder"), new ArrayList<Object>());
+
jspGenerator.doGenerate(null);
+
</source>
+
 
+
== Source Repository  ==
+
 
+
All the source code is stored in the Eclipse public source repository:
+
 
+
* JSP metamodel : https://dev.eclipse.org/svnroot/modeling/org.eclipse.mdt.modisco/plugins/trunk/org.eclipse.modisco.jee.jsp/
+
* JSP discoverer : https://dev.eclipse.org/svnroot/modeling/org.eclipse.mdt.modisco/plugins/trunk/org.eclipse.modisco.jee.jsp.discoverer/
+
* JSP generator : https://dev.eclipse.org/svnroot/modeling/org.eclipse.mdt.modisco/plugins/trunk/org.eclipse.modisco.jee.jsp.generation/
+
 
+
{{MoDisco}}
+
[[Category:MoDisco]]
+

Latest revision as of 11:48, 2 April 2012

  1. REDIRECT MoDisco/Moved To Help Center

Back to the top