Thanks for your efforts in developing best practices. I think it is important to polish
it.
1. (small one) In cancel action you should specify immediate="true". If not you
will not be able to cancel without posting data back. For instance, you do not need
validation if you want to cancel ;-)
<h:commandLink value="Cancel" action="#{employeeBean.cancel}"
immediate="true" />
2. Page flows are extremely convenient and easy to use. It removes all "flow
logic" from beans and from views also. You bean methods can be void (return nothing).
And you page actions do not need method binding. Thus one view can be reused in different
scenarios (page flows). By clicking SAVE, it just signals "save" and in
different scenarios can be executed different methods.
<h:commandLink value="Save" action="save" />
| <h:commandLink value="Delete" action="delete"
rendered="#{not employeeBean.new}" />
| <h:commandLink value="Cancel" action="cancel" />
|
You page flow logic can be visualized by the eclipse plug in. And changed separately from
a bean and view.
More over, you can change a page flows without restarting app and server :-)
Somewhere on your debug page, just put such an action.
public void reloadJBPM() {
| Contexts.removeFromAllContexts("org.jboss.seam.core.jbpm");
| Component.newInstance("org.jboss.seam.core.jbpm");
| }
|
3. For all conditional logic like a context validation, decision making, changing
something in some cases, I suggest to consider to use the Drools (jBoss Rules). It fits
perfectly to jBpm (thanks to Gavin). See Seam sample ?drools?. After including Drools, in
my bean code there is no more "if" sentences :-) almost.
4. Look at facelets template capabilities, specially user defined tags (Tag Source Files).
With this you can create a building bricks for views.
Imaging that you have Person entity.
public class Person implements Serializable {
| private String fio;
| private PassportType passType;
| private String passNumber;
| .........
| }
|
Tag file:
....
| <ui:component
xmlns="http://www.w3.org/1999/xhtml"
|
xmlns:f="http://java.sun.com/jsf/core"
|
xmlns:h="http://java.sun.com/jsf/html">
| <div class="panel">
| <div class="entry">
| <div class="label">FIO</div>
| <div class="input">
| <input id="#{id}_fio" type="text"
jsfc="h:inputText" value="#{person.fio}"/>
| <br/><span class="errors"><h:message
for="#{id}_fio" /></span>
| </div>
| </div>
| <div class="entry">
| <div class="label">Document</div>
| <div class="combo">
| <h:selectOneMenu id="#{id}_passType" class="combo"
value="#{person.passType}" converter="#{PassTypeList.converter}">
| <f:selectItems value="#{PassTypeList.selectItems}" />
| </h:selectOneMenu>
| <br/><span class="errors"><h:message
for="#{id}_passType" /></span>
| </div>
| </div>
| <div class="entry">
| <div class="label">Document number</div>
| <div class="input">
| <input id="#{id}_passNumber" type="text"
jsfc="h:inputText" value="#{person.passNumber}"/>
| <br/><span class="errors"><h:message
for="#{id}_passNumber" /></span>
| </div>
| </div>
| </div>
| </ui:component>
| ....
|
page code (*.xhtml)
....
| <my:person id="good" person=?#{bean.goodPerson}?/>
| <my:person id="bad" person=?#{bean.badPerson}?/>
| .....
|
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960624#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...