<H: column>
<H: commandlink action = "# {ticketsystem. Reply}">
<H: commandbutton value = "reply"/>
<F: Param name = "taskid" value = "# {task. ID}"/>
</H: commandlink>
</H: column>
</H: datatable>
In Seam applications integrated with jbpm/JBoss rules, developers can directly use seam annotations and components to drive business processes and rules engines, instead of having to master the Java APIs of specific jbpm and JBoss Rules separately.
Use itext to generate different views The itext library is an open source Java library widely used to generate PDF documents. However, using the itext API to create PDF documents is time consuming (think about the experience of using Dom to create XML documents or using swing to write the UI ).
Seam neatly integrates itext, JSF, and facelets. developers can generate dynamic PDF pages in the same simple way as JSF pages, you can even use a template on the pdf page.
Seam creates a special XHTML tag library for the PDF element and transparently calls itext when generating the page. The following example shows how to generate a pdf page with digital signatures supported in the seam application.
<P: document... Title = "Why seam" KEYWORDS = "mykeyword"
Subject = "seam" author = "seam team" creator = "seam PDF example app">
<P: Image Alignment = "right" Wrap = "true" value = "/jboss.jpg"/>
<P: font size = "24"> <P: paragraph spacingbefore = "16" spacingafter = "40">
Order # {currentorder. orderid}
</P: paragraph> </P: font>
<P: paragraph> dear # {currentorder. customername}, </P: paragraph>
<P: paragraph>... </P: paragraph>
<P: barcode type = "code128" code = "my barcode"/>
<P: Signature field = "my signature" size = "200 200 400"/>
</P: document>
Through the code, we can see that integration is seamless, and the page does not depend on itext. In fact, replacing itext with other commercial PDF libraries can still work on pages, which is the charm of seam integration.
Advanced Task Scheduler In many enterprise applications, support for automatic repetitive tasks is very important. In standard ejbs, you can use the EJB timer API to schedule repeated events at a fixed interval. However, in practical applications, we need to trigger more advanced scheduling services than at a fixed interval.
Currently, the popular open-source Java scheduling library is the quartz library. However, to use quartz, developers still need to write "glue" code to integrate the specific APIs and Object Model of quartz.
Seam integrates quartz to schedule asynchronous repetitive tasks. You only need to add the @ asynchronous annotation to the method of repetitive work. You can input the start/end of the task.
Time, interval, or Kelon expression (Cron
String), you can also annotate these specific parameters in the method definition. The specified method returns the quartztriggerhandler object.
And then use the quartztriggerhandler object to pause or cancel the task. You can also save the quartztriggerhandler object to the database
For later use.
@ Asynchronous
Public quartztriggerhandle schedulepayment (
@ Expiration date when,
@ Intervalcron string Cron,
@ Finalexpiration date stoptime
... Any other call parameters ...) {
// Do the repeating or long running task
}
In the following example, the schedulepayment () method is set to run at 02:10 P.M. and 02:44 P.M. on every Wednesday, January 1, March. You can add the called code in the Web UI event processing method, so that when the button is pressed, repeated events will be scheduled to the scheduler.
Quartztriggerhandle handle =
Processor. schedulepayment (payment. getpaymentdate (),
"0 10, 44 14? 3 wed ",
Payment. getpaymentenddate (),
Payment );
Payment. setquartztriggerhandle (handle );
// Save payment to DB
// Later...
// Retrieve payment from DB
// Cancel the remaining scheduled tasks
Payment. getquartztriggerhandle (). Cancel ();
The example shows that developers do not need to manually start the quartz scheduler, create a quartz trigger and task, but only need to use the seam annotation pojos.
Unified Programming Model So far, we have introduced many examples of integrating different frameworks by using consistent programming models. In addition to the above, there are many other frameworks. However, due to space limitations, we cannot introduce all the frameworks. The following describes how seam integrates these frameworks. The key three elements of the seam programming model are:
Pojos Annotation: All Java components in the seam application are annotated pojo classes. Seam manages interactions between them through bidirectional dependency injection. In addition, there are no other component models in seam.
XHTMLDisplay page: All view (UI) pages are displayed through the XHTML file. Apart from the standard JSF tag, seam also defines many of its own UI tags, including pdf ui tags. Seam also adds the Ajax JSF library, such as ajax4jsf, richfaces, and icefaces.
Expression Language: The XHTML page uses the JSF Expression Language (EL) to reference Java components in seam. Seam enhances the standard El syntax to support method parameters, and enables El to be used in all xml configuration files and test scripts.
With these cool features, seam's programming model will become exceptionally simple. As long as you have some JSF basics, your learning curve will be very flat.
Download seam, check the instance, and write the seam code happily. Everything is so simple!
From: http://www.dojochina.com/index.php? Q = blog/8377