[JBoss Seam] - Force method to be run before page redirect (no pages.xml!)
by w17chm4n
Hi again ;)
I have another problem with seam. Is there a way to force seam to run some method before it redirects to the page ? And is it possible that seam is cache`ing lists used as datamodels ?
If you are a bit confussed, let me explain.
Here I have my view
| <h:dataTable styleClass="dataTable" columnClasses="categoryName" var="question" value="#{cat.questionList}">
| <h:column>
| <h:outputText value="#{question.questionText}"/>
| </h:column>
| <h:column>
| <h:commandButton type="button" image="./images/tbl_ico_del.png" style="border: none" action="#{QuestionController.removeQuestion(question)}"/>
| </h:column>
| </h:dataTable>
|
As U can see it uses questionCategoryList generated by the bean below.
| @Stateless
| @Name("QuestionCategoryController")
| public class QuestionCategoryControllerBean implements QuestionCategoryController {
|
| @Logger
| private Log log;
|
| @In(create = true)
| private QuestionCategoryManager questionCategoryManager;
|
| @In(create = true)
| private QuestionCategory questionCategory;
|
| @DataModel
| private List<QuestionCategory> questionCategoryList;
|
| @In(required = true)
| private FieldValidator fieldValidator;
|
| public void addCategory() {
| if(fieldValidator.validate(questionCategory,"addCategoryForm","categoryName")) {
| questionCategoryManager.addCategory(this.questionCategory);
| this.questionCategory = null;
| this.questionCategoryList = null;
| }
| }
|
| @SuppressWarnings("unchecked")
| public void removeSelectedCategories() {
| QuestionCategory qc;
| Iterator it = questionCategoryList.iterator();
|
| while(it.hasNext()) {
| qc = (QuestionCategory) it.next();
|
| if(qc.isSelected()) {
| questionCategoryManager.removeCategory(qc);
| }
| }
|
| this.questionCategoryList = null;
| }
|
| public void removeCategory(QuestionCategory questionCategory) {
| questionCategoryManager.removeCategory(questionCategory);
| this.questionCategory = null;
| this.questionCategoryList = null;
| }
|
| public QuestionCategory getQuestionCategory() {
| return questionCategory;
| }
|
| public void setQuestionCategory(QuestionCategory questionCategory) {
| this.questionCategory = questionCategory;
| }
|
| @Factory("questionCategoryList")
| public void createQuestionCategoryList() {
| this.questionCategoryList = this.questionCategoryManager.getAllQuestionCategories();
| }
|
| @Remove
| public void destroy() {
| }
| }
|
Well the view works, and it renders ok, but the problem is when I want to remove a question from the category by running #{QuestionController.removeQuestion(question)} from the view.
The question is removed from the database, but when the page reloads, it`s still in the list !
I`m removing question by using another bean
| @Stateless
| @Name("questionManager")
| public class QuestionManagerBean implements QuestionManager {
|
| @Logger
| Log log;
|
| @In
| private EntityManager entityManager;
|
| public void addQuestion(Question question) {
| question.setCreated(new Date());
| entityManager.persist(question);
| log.info("Question successfully persisted. [" + question.getQuestionText() + "]");
| }
|
| public void removeQuestion(Question question) {
| log.info("Removing question [" + question.getQuestionText() + "]");
| entityManager.flush();
| entityManager.remove(entityManager.merge(question));
| }
|
| public Question getQuestion(Question question) {
| return null;
| }
|
| @SuppressWarnings("unchecked")
| public List<Question> getAllQuestions() {
| return entityManager.createQuery("from Question q").getResultList();
| }
|
| @Remove
| public void destroy() {}
|
| }
|
After putting some breakepoints and running this metod from view I found this:
| 17:04:36,893 INFO [QuestionCategoryManagerBean] Reciving QuestionCategory list
| 17:04:37,494 INFO [QuestionManagerBean] Removing question [hdfghdfghf]
|
As far as I`m concerned, as the questionCategoryList is generated by a stateless bean, the list has to be recived from the database everytime my code recals to it. So as I want to remove question from some category, seam needs to get current list from the database, then lazy-fetch the question, inject it to the metod, and pass to the removeQuestion method in the questionManagerBean. It`s allright, but why Seam isn`t refreshing the list after the question is removed ? I mean that even though question is removed form the database, the list rendered as dataModel on view by dataTable, just after reloading the page, the question is still on the list. But what is strange, when I hit reload on my browser (F5 or sth) the list is recived from the database once again and rendered view is correct, without removed question !
I`ve tryed a couple of my ideas (including <action execute="refresh_this_stupid_list> setted in the view section in pages.xml) to fix this crap, even something like this
| @In(value="#{questionCategoryList}")
| private ListDataModel tmp;
| .
| .
| .
| public void removeQuestion(Question question) {
| if(question.getQuestionType().getId().equals(questionTypeManager.getQuestionTypeByName(propertiesManager.get("questiontype.input")).getId())) {
| questionManager.removeQuestion(question);
| } else {
| answerManager.removeAnswers(question.getAnswers());
| questionManager.removeQuestion(question);
| }
| tmp.setWrappedData(questionCategoryManager.getAllQuestionCategories());
| }
|
But even though that in logs it looked allright
| 17:04:36,893 INFO [QuestionCategoryManagerBean] Reciving QuestionCategory list
| 17:04:37,494 INFO [QuestionManagerBean] Removing question [hdfghdfghf]
| 17:04:37,516 INFO [QuestionCategoryManagerBean] Reciving QuestionCategory list
|
The list rendered on the view, wasn`t refreshed and contained removed question.
Any idea how to work this thing out ?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4123100#4123100
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4123100
18 years, 4 months
[JBoss Seam] - 2.0.1-SNAPSHOT and JBoss 4.2.2
by anewton
I'm seeing an odd problem when deploying a Seam EAR to JBoss 4.2.2. I get the following exception:
| 11:03:05,109 ERROR [[/public]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
| java.lang.ClassFormatError: Illegal class modifiers in class org/jboss/seam/async/package-info: 0x1600
| at java.lang.ClassLoader.defineClass1(Native Method)
| at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
| at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
| at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1814)
| at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:872)
| at org.jboss.web.tomcat.service.WebAppClassLoader.findClass(WebAppClassLoader.java:139)
| at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1325)
| at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
| at org.jboss.seam.deployment.NamespaceDeploymentHandler.getPackage(NamespaceDeploymentHandler.java:69)
| at org.jboss.seam.deployment.NamespaceDeploymentHandler.handle(NamespaceDeploymentHandler.java:44)
| at org.jboss.seam.deployment.DeploymentStrategy.handle(DeploymentStrategy.java:81)
| at org.jboss.seam.deployment.AbstractScanner.handleItem(AbstractScanner.java:30)
| at org.jboss.seam.deployment.URLScanner.handleArchiveByFile(URLScanner.java:117)
| at org.jboss.seam.deployment.URLScanner.handle(URLScanner.java:98)
| at org.jboss.seam.deployment.URLScanner.scanResources(URLScanner.java:81)
| at org.jboss.seam.deployment.StandardDeploymentStrategy.scan(StandardDeploymentStrategy.java:67)
| at org.jboss.seam.init.Initialization.create(Initialization.java:102)
| at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34)
| at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856)
| at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)
| at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790)
| at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770)
| at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
| 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.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
| at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.apache.catalina.core.StandardContext.init(StandardContext.java:5312)
| 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.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
| at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301)
| at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
| at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
| at org.jboss.web.WebModule.startModule(WebModule.java:83)
| at org.jboss.web.WebModule.startService(WebModule.java:61)
| at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
| at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
| at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
| at $Proxy0.start(Unknown Source)
| at org.jboss.system.ServiceController.start(ServiceController.java:417)
| at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy44.start(Unknown Source)
| at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
| 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.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
| at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
| at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
| at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:87)
| at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
| at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy45.start(Unknown Source)
| at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
| at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1015)
| at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
| at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
| at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy9.deploy(Unknown Source)
| at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
| at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:610)
| at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
| at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
| at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
| 11:03:05,113 ERROR [StandardContext] Error listenerStart
| 11:03:05,113 ERROR [StandardContext] Context [/public] startup failed due to previous errors
|
I noticed this yesterday briefly when my SeamTests started throwing the same exception, except the problem went away after Maven grabbed the new snapshots (of either Seam or JBoss Embedded, I'm not sure which).
Any ideas.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4123091#4123091
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4123091
18 years, 4 months
[Installation, Configuration & DEPLOYMENT] - Re: Configuration JNDI
by jaikiran
"benjiii" wrote :
|
| (;-) you remember - I'm just a rookie trying to get some knowledge, but haven't yet...)
Ok, so here's how the ejb-local-ref/ejb-ref work.
When you specify the ejb-ref-name then the bean will be bound with the name that you specified in the ejb-ref-name in the JNDI tree in the java:comp/env namespace. So in your case, you specifed the ejb-ref-name as ejb/DataAccessFacade. So the bean will be bound to java:comp/env/ejb/DataAccessFacade. Hence the lookup string in your servlet should be:
| DataAccessFacadeLocalHome dataFacadeHome = (DataAccessFacadeLocalHome)getContext().lookup("java:comp/env/ejb/DataAccessFacade");
And finally, the best way to debug NameNotFoundException is to look at the JNDI tree:
- Go to http://< server>:< port>/jmx-console (Ex: http://localhost:8080/jmx-console)
- Search for service=JNDIView on the jmx-console page
- Click on that link
- On the page that comes up click on the Invoke button beside the list() method
- The page that comes up will show the contents of the JNDI tree.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4123088#4123088
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4123088
18 years, 4 months
[JBoss Seam] - Re: Using rich:datascroller With Seam and Hibernate Paginati
by neilac333
Thanks, Alexander. I actually caught that before. It is true that the approach you directed me to isn't the same as writing my own component, but man is it a lot of code!
Besides, even if I were to create my own DataModel, I am currently using the @DataModel and @DataModelSelection annotations in the context of a conversation, and I don't know how that process works with my own DataModel. I suppose I can outject my own DataModel like any other object, but how can I get the selection into the conversational context in an easy way?
It seems to me easier to just add my own navigation buttons and allow the user to page through the results that way. After all, most of the logic for handling that is in my Seam component.
I would appreciate any insight into some alternative approaches that others may have tried would be much appreciated.
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4123086#4123086
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4123086
18 years, 4 months