[JBoss Seam] - Re: Data disappeared when clicking on Conversation outjectio
by gus888
"jacob.orshalick" wrote : Without some code (the view, the navigation, etc), I don't think anyone is going to be able to help here...
Thank you, Jacob. Following are my code snippets:pages.xml
| <page view-id="*">
| <navigation>
| <rule if-outcome="emailList">
| <redirect view-id="/emails.xhtml"/>
| </rule>
| <rule if-outcome="phoneList">
| <redirect view-id="/phones.xhtml"/>
| </rule>
| ....
|
| sidebar.xhtml
| <div>
| <ice:commandLink value="Contact Emails"
| action="#{contactServicer.retrieveEmails}"/>
| </div>
|
| <div>
| <ice:commandLink value="Contact Phones"
| action="#{contactServicer.retrievePhones}"/>
| </div>
| ...
|
| emails.xhtml
| <ice:panelSeries style="clear: both;"
| value="#{emailList}"
| var="email" rendered="#{!empty emailList}">
| <div class="row">
| <ice:outputText value="#{email.emailAddress}"/>
| </div>
| ....
|
| phones.xhtml
| <ice:panelSeries style="clear: both;"
| value="#{phoneList}"
| var="phone" rendered="#{!empty phoneList}">
| <div class="row">
| <ice:outputText value="#{phone.phoneNumber}"/>
| </div>
| ....
|
| @Name("contactServicer")
| @Stateless
| @Scope(ScopeType.STATELESS)
| public class ContactServicerBean implements ContactServicer {
|
|
| @Out(required=false, scope=ScopeType.CONVERSATION) //EVENT and PAGE don't work
| private List<Email> emailList;
|
| @Out(required=false, scope=ScopeType.CONVERSATION) //EVENT and PAGE don't work
| private List<Phone> phoneList;
|
|
| public String retrieveEmails() {
| emailList = em.createNamedQuery("...").getResultList();
| return "emailList"
| }
|
| public String retrievePhones() {
| phoneList = em.createNamedQuery("...").getResultList();
| return "phoneList";
| }
|
| ....
| }
|
"jacob.orshalick" wrote : If you outject to the conversation, you must begin a long-running conversation to have the data available on the next request (the next click of a commandLink). Otherwise, the temporary conversation will be destroyed and your data is gone on the next request.I don't know which pattern is good for enterprise project based on my codes above. Seam wiki pagination sample is using Stateless bean + Event outjection, but I couldn't make this work.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118509#4118509
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118509
18 years, 3 months
[JBoss Seam] - Custom interceptors do not work with super classes
by Kragoth
When creating my own interceptor I was hoping to have super class that all my classes could extend that would give them my interceptor.
However, the initInterceptors method in the SEAM Component.java does not scan superclasses for annotations.
So I have the following code.
My Annotation
| package gekko.web.services;
|
| import static java.lang.annotation.ElementType.TYPE;
| import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
| import java.lang.annotation.Retention;
| import java.lang.annotation.Target;
|
| import org.jboss.seam.annotations.intercept.Interceptors;
|
| @Target(TYPE)
| @Retention(RUNTIME)
| @Interceptors(GekkoSpringInjector.class)
| public @interface SpringAutowirable {}
|
My Super class
| package gekko.web.actionbean;
|
| import gekko.web.services.SpringAutowirable;
|
| @SpringAutowirable
| public class AbstractSeamComponent {
|
| }
|
And finally my sub-class
| package gekko.web.actionbean.enquiry;
|
| *imports stripped*
|
| @Name("catSubcatEnquiry")
| @Scope(PAGE)
| public class CatSubcatEnquiry extends AbstractSeamComponent {
|
| .....
|
| }
|
If I use the extends Superclass the Interceptor never fires.
If I change this and make an interface like
| package gekko.web.actionbean.enquiry;
|
| import gekko.web.services.SpringAutowirable;
|
| @SpringAutowirable
| public interface TestInterface {
|
| }
|
and use
| @Name("catSubcatEnquiry")
| @Scope(PAGE)
| public class CatSubcatEnquiry implements TestInterface {
| ...
| }
|
That works fine.
If you have a look at the Spring AnnotationUtils.java you will find that in there findAnnotation method it does look in super classes.
As seen here.
| public static <A extends Annotation> A findAnnotation(Method method, final Class<A> annotationType) {
|
| if (!annotationType.isAnnotation()) {
| throw new IllegalArgumentException(annotationType + " is not an annotation");
| }
| A annotation = getAnnotation(method, annotationType);
| Class<?> cl = method.getDeclaringClass();
| while (annotation == null) {
| cl = cl.getSuperclass();
| if (cl == null || cl.equals(Object.class)) {
| break;
| }
| try {
| method = cl.getDeclaredMethod(method.getName(), method.getParameterTypes());
| annotation = getAnnotation(method, annotationType);
| }
| catch (final NoSuchMethodException ex) {
| // We're done...
| }
| }
| return annotation;
| }
|
Is there a possiblity of making Seam behave the same way?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118502#4118502
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118502
18 years, 3 months