Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "MoDisco/Components/JSP/Documentation/0.9"
(→JSP Discoverer) |
(→JSP Discoverer) |
||
Line 26: | Line 26: | ||
− | [[Image:JSP_Browser_Menu2. | + | [[Image:JSP_Browser_Menu2.PNG |frame|center|Menus in Eclipse to create JSP model from source code]] |
You can also select one or several files to create a model for each one of them | You can also select one or several files to create a model for each one of them | ||
− | [[Image:JSP_DiscoverFromFiles2. | + | [[Image:JSP_DiscoverFromFiles2.PNG|frame|center|Menus in Eclipse to create JSP model from several files]] |
Revision as of 10:57, 15 June 2010
DEPRECATED use Template:MoDiscoTabs and Template:MoDiscoTab as explain here : Wiki Template for MoDisco
JSP Metamodel
The Modisco JSP Metamodel inherits from the Modisco XML one :
Inheritance was chosen because a JSP page uses the tag mechanism, attributes and comments, and is nearly well formed regarding the XML Metamodel.
According to the "Java Server Pages Specifications Version 1.2", JSP content is divided into 4 categories :
- JSP Scripts :
- JSP Scriplet :
<% int variable = 0;%>
- JSP Expression :
<%= variable %>
- JSP Declaration :
<%! int variable = 0; %>
- JSP Scriplet :
- JSP Actions :
<myPrefix:myAction arg1="value" />
- JSP Standard Action :
<jsp:getProperty name="beanName" property="propertyNamef" />
- JSP Standard Action :
- JSP Directive :
<%@ include file="myFilePath" %>
- JSP TagLib :
<%@ taglib prefix="myPrefix" uri="taglib/mytag.tld" %>
- JSP TagLib :
- Comments :
<%-- This is a JSP comment --%>
JSP Discoverer
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, you can quickly create the JSP model of your application (see next Figure).
You can also select one or several files to create a model for each one of them
Once launched, a progress bar will appear at the bottom of the window as soon as the operation begins. Depending on the size of your application, the reverse engineering process might take some time to complete (see next Figure).
At the end of the process, the newly created model files are added to the root of your project and are automatically opened in the default editor (see next Figure).
.jspxmi files can be opened in the Sample Ecore Model Editor (see next Figure).
They can also be opened in the MoDisco model browser (see next Figure).
Discovery Limitations
Because JSP language is used to generated some content, it can be placed almost anywhere in the file, which imply certain limitations:
This is why the "isTagFragment : EBoolean" attribute was added. In fact, everything contain in a tag declaration as in its body is considered as children. It is indeed necessary to be able to differentiate whether the JSP tag is used to generate the tag description, or its body.
Some way of implementing JSP might cause some problem with the parser, especially for tag's attributes evaluation. What is expected to be found is some kind of syntax like :
name="value"
or name='value'
and even name=value
Sometimes we faced implementations like :
<tag name=" <% if(condition){ %> value1" <% }else{ %> value2" <% } %> >
The parser finds the opening double quote for the attribute's value, then looks for the closing one.
Returned value will be: with an exception raised on the last double quote, because '=' is expected.
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.