Contribution:
seam
Intent
Web application development with Language:Java and the Technology:Seam framework
Motivation
Technology:Seam provides a great support for the development of web applications in Language:Java with easy access control and an integrated persistence layer. It combines the popular Technology:JSF (please visit Contribution:jsf for more information) approach for UI programming with Technology:Hibernate and Technology:JPA. Both persistence technologies are directly integrated into the web-application framework.
Illustration
Technology:Seam is based on the three-tier architecture. Since the presentation is covered by Technology:JSF, the focus of the Seam framework is the business and data access layer. This section illustrates the major components of the Seam framework and introduces its rights management.
Presentation
The presentation layer is based on the MVC architecture, because it is the main architecture of the Technology:JSF framework. From this it follows, that the view consists of Technology:Facelets. We will start our presentation illustration with the first page of the application: the company view. It contains four parts, at which there are two textfields for the name and the total of the company and two buttons for the department list and the cut of the company. In theory, the view is designed to show more than one company, but this is not demanded by the feature model.
...
<rich:dataTable value="#{allCompanies}" var="c" width="300px">
<rich:column>
<f:facet name="header">Name</f:facet>
<h:outputText value="#{c.name}" />
</rich:column>
<rich:column>
<f:facet name="header">Total salaries</f:facet>
<h:outputText value="#{c.total()}" />
</rich:column>
<rich:column>
<s:button value="Show details" action="#{companyAction.showDetails()}" />
</rich:column>
<rich:column>
<s:button value="Cut salaries" action="#{companyAction.cutSalaries()}" />
</rich:column>
</rich:datatable>
...
The
<rich:dataTable ...> ... </rich:datatable>
width="300px"
"#{allCompanies}"
allCompanies
var="c"
<rich:column> ... </rich:column>
<s:button value="Cut salaries" action="#{companyAction.cutSalaries()}"/>
The following example illustrates the
cutSalaries()
...
public String cutSalaries() {
try {
// The method cuts the salaries for the selected company.
companyService.cutSalaries(selectedCompany);
// If the call is successful, a corresponding message is displayed.
facesMessages.add(FacesMessage.SEVERITY INFO, "The cut salary operation was successfully applied.");
}
catch(Exception e) {
// If an exception occures, an error message is displayed.
facesMessages.add(FacesMessage.SEVERITY ERROR, "Error when trying to cut salaries. " + e.getMessage());
e.printStackTrace();
}
// The framework expects a view name for loading the next view. If this name is 'null', the current view will reloads.
return null;
}
...
The action invokes the
cutSalaries(selectedCompany)
null
Business and Data access
The business layer manages the access control of the application. In addition, it is connected to the persistence layer, which is implemented with Technology:JPA. On cut, the following method of the service class CompanyService is invoked:
...
// The annotation manages the access control for this method.
@Restrict("#{s:hasRole('admin')}")
public void cutSalaries(Company company) {
company.cut();
entityManager.merge(company);
}
...
A simple annotation
@Restrict
entityManager
Architecture
- The Technology:Facelets defining the view are located in the folder this!!view. The folder contains layout templates, images and style sheets as well, which are provided directly by the Technology:Seam web-application framework.
- The Java bean CompanyAction.java is located in this!!src/hot/org/softlang/web and provides the connection point to the business layer.
- The entity classes for the company are located in the this!!src/main/org/softlang/model package.
- The Technology:Seam service class is located in the this!!src/main/org/softlang/services package.
Usage
This application requires the Technology:Eclipse and Technology:JBoss Application Server (Version 4.2.x). After downloading and installing both, follow these steps:
- Import the seam project from your file system to Technology:Eclipse as a java project.
- Change the this!!build.properties file located in the projects base folder. The jboss.home-property must refer to your Technology:JBoss Application Server location: jboss.home = <your></your>.
- Run the seam project as ant build in eclipse (Right click on the build.xml file -> Run As -> Ant Script).
- Start JBoss using either <your>/bin/run.bat for Windows OS or <your></your></bin/run.sh></your>for Unix OS.
- Start a Web browser and go to http://localhost:8080/seam
There are no revisions for this page.
User contributions
User edits
Syntax for editing wiki
For you are available next options:will make text bold.
will make text italic.
will make text underlined.
will make text striked.
will allow you to paste code headline into the page.
will allow you to link into the page.
will allow you to paste code with syntax highlight into the page. You will need to define used programming language.
will allow you to paste image into the page.
is list with bullets.
is list with numbers.
will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.
will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.
will allow your to insert code snippets from @worker.
Syntax for editing wiki
For you are available next options:will make text bold.
will make text italic.
will make text underlined.
will make text striked.
will allow you to paste code headline into the page.
will allow you to link into the page.
will allow you to paste code with syntax highlight into the page. You will need to define used programming language.
will allow you to paste image into the page.
is list with bullets.
is list with numbers.
will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.
will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.
will allow your to insert code snippets from @worker.