[JBoss Seam] - Re: Avoiding the DRY Principle with beans
by denis-karpov
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#3960624
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960624
19 years, 9 months
[JBoss Seam] - Logging using component from different contexts
by rlhr
I'm using JBoss 4.0.4.GA + Seam 1.0.1.GA
I try to log some debug information in a remote method of a SFSB.
When I use:
log.debug("***** The user name is : " + user.getName()); // [1]
Everything is fine.
When I use:
log.debug("***** The user name is : #{user.name}"); // [2]
I get a NullPointerException. I use this in some other places and
it works fine.
Looking again at the doc, I came to the conclusion that [2] works only if the seam components are in the same context (which is not the case here).
If someone can confirm this, so I don't need to worry about something wrong in the code, that would be great.
Thanks.
Below is the code and stacktrace.
@Stateful
| @Name("test")
| @Scope(ScopeType.EVENT)
| public class TestAction implements Test {
|
| @In(create = true)
| @Out(scope = ScopeType.SESSION)
| private User user;
|
| public String doSomething() {
|
| if ((user.getName() == null) || (user.getName().equals(""))) {
| log.debug("***** No user name");
| return "";
| }
| log.debug("***** The user name is : #{user.name}"); // throws an exception
| log.debug("***** The user name is : " + user.getName()); // works fine
| return user.getName();
| }
|
| @Destroy
| @Remove
| public void destroy() {
| }
| }
|
|
@Local
| public interface Sites {
|
| @WebRemote
| public String doSomething();
|
| public void destroy();
| }
|
@Stateless
| @Name("user")
| @Scope(ScopeType.SESSION)
| public class UserBean implements User {
|
| private String name = null;
|
| public UserBean() {
| }
|
| public UserBean(String name) {
| this.name = name;
| }
|
| public String getName() {
| return name;
| }
|
| public void setName(String name) {
| this.name = name;
| }
| }
|
|
@Local
| public interface User extends Serializable {
|
| public String getName();
| public void setName(String name);
| }
|
|
I get the following exception:
2006-07-25 11:16:34,000 WARN [org.jboss.seam.core.Interpolator] exception interpolating string: ***** The user name is : #{user.name}
| java.lang.NullPointerException
| at org.jboss.seam.core.Interpolator.interpolate(Interpolator.java:70)
| at org.jboss.seam.log.LogImpl.interpolate(LogImpl.java:158)
| at org.jboss.seam.log.LogImpl.debug(LogImpl.java:78)
| at com.myapp.app.actions.header.TestAction.doSomething(TestAction.java:67)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
| at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
| at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
| at org.jboss.seam.interceptors.ValidationInterceptor.validateTargetComponent(ValidationInterceptor.java:64)
| at sun.reflect.GeneratedMethodAccessor342.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
| at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
| at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
| at org.jboss.seam.interceptors.OutcomeInterceptor.interceptOutcome(OutcomeInterceptor.java:21)
| at sun.reflect.GeneratedMethodAccessor341.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
| at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
| at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
| at org.jboss.seam.interceptors.RollbackInterceptor.rollbackIfNecessary(RollbackInterceptor.java:30)
| at sun.reflect.GeneratedMethodAccessor340.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
| at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
| at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
| at org.jboss.seam.interceptors.BijectionInterceptor.bijectTargetComponent(BijectionInterceptor.java:33)
| at sun.reflect.GeneratedMethodAccessor339.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
| at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
| at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
| at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:82)
| at sun.reflect.GeneratedMethodAccessor338.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
| at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
| at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
| at org.jboss.seam.interceptors.BusinessProcessInterceptor.manageBusinessProcessContext(BusinessProcessInterceptor.java:60)
| at sun.reflect.GeneratedMethodAccessor337.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
| at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
| at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
| at org.jboss.seam.interceptors.RemoveInterceptor.removeIfNecessary(RemoveInterceptor.java:39)
| at sun.reflect.GeneratedMethodAccessor336.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
| at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
| at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
| at org.jboss.seam.ejb.SeamInterceptor.aroundInvokeInContexts(SeamInterceptor.java:73)
| at org.jboss.seam.ejb.SeamInterceptor.aroundInvoke(SeamInterceptor.java:45)
| at sun.reflect.GeneratedMethodAccessor326.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
| at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
| at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:81)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:188)
| at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
| at $Proxy386.getCurrentLocation(Unknown Source)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.seam.remoting.Call.execute(Call.java:121)
| at org.jboss.seam.remoting.ExecutionHandler.handle(ExecutionHandler.java:92)
| at org.jboss.seam.remoting.SeamRemotingServlet.doPost(SeamRemotingServlet.java:56)
| at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
| at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
| at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
| at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
| at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
| at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
| at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
| at java.lang.Thread.run(Thread.java:595)
| 2006-07-25 11:16:34,093 DEBUG [com.myapp.app.actions.header.TestAction] ***** The user name is :
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960623#3960623
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960623
19 years, 9 months
[JBoss jBPM] - Re: 3.2 Timeline?
by alf_dave
Thanks for the prompt responses.
Given our timelines (heading for a 1.4 qa cycle in sept), I think it's best to stick with 3.1.2 for now. However, your plans for 3.2 sound ideal, allowing us to try early 3.2 drops on our 1.5 dev line.
Initially, we're going to build JSF components (inbox, start process, task view ) that integrate with the rest of Alfresco's JSF based UI and look & feel. Over time, we'll introduce more workflow interaction within Alfresco.
I'm not the JSF expert, but members of our team have now gained deep experience from developing the Alfresco UI (and DCTM's Webtop) of this type of technology. I'm sure we can help each other.
Our WCM team will be introducing Chiba into our stack, so who knows, we may in the future use xforms for managing tasks etc. We're just taking it step-by-step for now :-)
Regards,
David
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960622#3960622
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960622
19 years, 9 months