voyent
Messages posted by: caioformiga  XML
Profile for caioformiga -> Messages posted by caioformiga [9]
Author Message
Dude, I was hading headache to do something similar... then after read doc and a few posts at forum such as this one, I just followed the instructions in this link http://www.icefaces.org/JForum/posts/list/14125.page and it works.

If after reading you can't do, post here again that I will give more tips, but generally speaking you must do:
1 - define a managed-bean with application scope (avoid huge Object, instead of that, in a scenario described just the id (primary key) from your table should be enough) which will store the product from user/application interaction,
2 - then in your jsp/jpsx/xhtml page use normal Expression Language as {#appBeanName.value} to store the value.
3 - use the code below to store this value at the PortletSession APPLICATION_SCOPE
Code:
 // I defined this methods as static cause they are encapsulated in an Util class to handle/ //manager the IPC using AjaxPush. 
 public static Object getPortletSessionAttribute(String key){
 		Object portletSessionAttribute = null;		
 		Object sessObj = FacesContext.getCurrentInstance().getExternalContext().getSession(false);                
         if (sessObj instanceof PortletSession) {
              PortletSession portletSess = (PortletSession) sessObj;
              portletSessionAttribute = portletSess.getAttribute(key, PortletSession.APPLICATION_SCOPE);        									
              System.out.println(">>>>>>>>> portletSessionAttribute stored at \n"
  		 			+"portlet session: "+ ((PortletSession) sessObj).getPortletContext().toString()
   					+"\n name: "+key
  		 			+"\n value "+portletSessionAttribute.toString());	                        
         }
 		return portletSessionAttribute;
 	}
 

4 - finally use the code below to retrieve the stored value from PortletSession
Code:
 // I defined this methods as static cause they are encapsulated in an Util class to handle/ //manager the IPC using AjaxPush. 
 public static void setPortletSessionAttribute(String key, Object value){
 		Object portletSessionAttribute = null;		
 		Object sessObj = FacesContext.getCurrentInstance().getExternalContext().getSession(false);                
         if (sessObj instanceof PortletSession) {
              PortletSession portletSess = (PortletSession) sessObj;
              portletSess.setAttribute(key, value, PortletSession.APPLICATION_SCOPE);        									
              System.out.println(">>>>>>>>> portletSessionAttribute stored at \n"
             		 			+"portlet session: "+ ((PortletSession) sessObj).getPortletContext().toString()
              					+"\n name: "+key
             		 			+"\n value "+value.toString());	            
         }		
 	}
 




The liferay-service.jar and liferay-kernel.jar has different names, at least in the liferay-portal-5.2.3. Instead of the referenced names, the names are portal-service.jar and portal-kernel.jar respectively

ps: I know that this post is a bit old..but just to keep it updated and somehow contribute with the community.
I was reading about PhaseListerner and decided to check if it would solve my problem. So I created the class MyPortletBPhaseListener listed below and register at faces-config.xml inside the element <lifecycle>. Besides that I used one onDemmandRender (Portlat A) and one intervalRender (Portlat B) both inside a AjaxUtil class.

Code:
 public class MyPortletBPhaseListener implements PhaseListener {
 
 	private static MonitorController controller = getInstance();
 
         //it's necessary to have a intance of MonitorController class cuase this class has the 
         //method that should be invoked before render the page
 	public static MonitorController getInstance() {
 		if (controller == null) {
 			controller = new MonitorController();
 		}
 		return controller;
 	}
 
 	public static void setController(MonitorController controller) {
 		MonitorPortletPhaseListener.controller = controller;
 	}
 
 	public void beforePhase(PhaseEvent event) {				
 		String rootViewIdInvoked = event.getFacesContext().getViewRoot().getViewId();
                 //determines when the request render was fired by PortletA or PortletB, the value 
                 //of controller.ROOT_VIEW_ID is the identifier of Portlet B
 		if (controller.ROOT_VIEW_ID.equals(rootViewIdInvoked)) {
 			controller.getPreparePortlet();			
 		}					
 	}
 
 	public void afterPhase(PhaseEvent event) {
 		//do nothig
 	}
 	public PhaseId getPhaseId() {
 		return PhaseId.INVOKE_APPLICATION;
 	}
 }
 


That way I start my application...select one item in the combo box (Portlet A) and fires a AjaxUtil.immediateRender(), which will run the JSF lifecycle. Once I have my PhaseListener registered it will intercept the lifecycle execution when it reach the PhaseId.INVOKE_APPLICATION, but this request render was fired by PortletA so don't do anything. Just wait.

In Portlet B, by the other hand, it listen that one item was selected and then fires AjaxUtil.scheduleRender(), which will wait for 3 seconds (time define by intervalRender.setInterval()) and also will run the JSF lifecycle, but this time it will execute controller.getPreparePortlet(), cause it was the PortletB which request render. This method follows below, and will run preparePortlet(getInstitutionSelectedName()) to get the new values from the database and a new AjaxUtil.scheduleIntervalRender(), then I will have a loop, every 3 seconds the method controller.getPreparePortlet() will be invoked.

Code:
 public void getPreparePortlet(){
 		try {			
 			if (getIsInstitutionSelected()) {	
                                 //getting the new values from the database	
 				preparePortlet(getInstitutionSelectedName());
                                 //schedule a request render for 3 seconds
 				AjaxUtil.scheduleIntervalRender();
 			}
 		} catch (Exception ex) {
 			ex.printStackTrace();
 		}
 	}
 


For some unknown reason my data is not been updated. But I think that is the way to do it. Any suggestions are welcomed.
I have a Portlet A which has a comboBox and a Portle B where I must access the database and retrieve the values related to the value selected on Portlet A.

Once my Portlet B starts to "run" must update/refresh every 3seconds. I`m using a tintervalRender as follow below:

Code:
        //my intervalRender object
        public static IntervalRenderer groupAsyncIntervalRender;
 
        //this is my interval time
        public static final Long RENDER_INTERVAL = 3000L;
 
        //this method is invoked every time a Portlet A changes the value of a selectItem
         public static void scheduleIntervalRender() throws RenderingException{		
 		if (groupAsyncIntervalRender != null){		
 			groupAsyncIntervalRender.requestRender();
 		}			
 	}	
 
        //this method is used to set my interval (3seconds)
 	public static void setIntervalRender(long interval){
 		if (groupAsyncIntervalRender != null){
 			groupAsyncIntervalRender.setInterval(interval);
 		}				
 	}
 


When I invoke the method scheduleIntervalRender() it will schedule a update/refresh according to the time specified by setIntervalRender(), which is inside the constructor of my ManagedBean that is my controller for Portlet B.

My portlet B is been refreshed (InternalRender is working) but I`m not getting the new values from the database. I have a preparePortlet() method which guarantee that all the demanded conditions are valid, so I can't access my database straight through get and set from my ManagedBean, I must use this method.

So, how to force my portlet to invoke this method (preparePortlet()) before let intervalRender refresh the page?

Unfortunately, I haven't just doubts about this behavior, indeed I`m passing through similar problem.

Code:
 <ice:form>
      <ice:selectOneListbox id="institutionSelected"   size="1"                       					                                           
                                         value="#{monitorController.institutionSelected}"                                                                                                                            
                                         valueChangeListener="#{monitorController.institutionChanged}"
                                         partialSubmit="true">                                            
                         <f:selectItems id="cbInstituitionsSelectItems"
                                        value="#{monitorController.instituitionsSelectItems}"/>
       </ice:selectOneListbox>        				   
       <p>#{pageMsg.eventHandlerDesc}</p>
       <ice:dataTable value="#{monitorController.progressBarList}" var="progress">	
                         <ice:column rendered="#{progress.isRendered}" colspan="2">
 		                    <f:facet name="header">
 		                        <ice:outputText value="#{pageMsg.lbColInstitutionName}"/>
 		                    </f:facet>		                 													
 		                    <ice:outputText value="#{progress.name}"/>		               		                   
 		         </ice:column>
 		         <ice:column rendered="#{progress.isRendered}">
 		                    <f:facet name="header">
 		                        <ice:outputText value="#{pageMsg.lbColPercent}"/>
 		                    </f:facet>
 		                    <ice:outputProgress value="#{progress.percent}" />
 		          </ice:column>
      </ice:dataTable>   	                	                	               	            		
 </ice:form>
 


I have a </ice:selectOneListbox> component populated with a list of Institutions like INST 1 and INST 2. Then after selectOneListBox changes its value the method institutionChanged is invoked.

Code:
 public void institutionChanged(ValueChangeEvent event) {						
 		if ((event.getPhaseId().equals(PhaseId.UPDATE_MODEL_VALUES)) && 
    		   ((! "".equals(institutionSelected)) && (institutionSelected != null))) {			
 			System.out.println("Creating ProgressBar List ====================>");		
 			createProgressBarList();											
 		} else {
 			event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
 			event.queue();
 			return;
 		}
 	}
 


This method is responsible to populate my progressBarList, that is the datamodel associated to <ice:dataTable>, but during this Exception is throw:


08:02:09,207 ERROR [ReceiveSendUpdates:80] Exception occured during rendering on http://192.168.1.152:8080/ProgressMonitor/block/send-receive-updates [/pages/monitorTest.jspx]
javax.faces.FacesException: Exception while calling broadcast on component : {Component-Path : [Class: com.icesoft.faces.application.SettableLocaleViewRoot,ViewId: /pages/monitorTest.jspx][Class: com.icesoft.faces.component.portlet.Portlet,Id: _BankProcessMonitor_WAR_ProgressMonitor_INSTANCE_Bt4F_][Class: com.icesoft.faces.component.ext.HtmlForm,Id: _BankProcessMonitor_WAR_ProgressMonitor_INSTANCE_Bt4F_j_id6][Class: com.icesoft.faces.component.ext.HtmlSelectOneListbox,Id: institutionSelected]}
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:494)
at javax.faces.component.UIInput.broadcast(UIInput.java:196)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:292)
at javax.faces.component.UIViewRoot.process(UIViewRoot.java:209)
at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:105)
at org.apache.myfaces.lifecycle.UpdateModelValuesExecutor.execute(UpdateModelValuesExecutor.java:33)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:103)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:76)
at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:18)
at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle(ReceiveSendUpdates.java:132)
at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(ReceiveSendUpdates.java:74)
at com.icesoft.faces.webapp.http.core.RequestVerifier.service(RequestVerifier.java:31)
at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24)
at com.icesoft.faces.webapp.http.servlet.BasicAdaptingServlet.service(BasicAdaptingServlet.java:16)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:53)
at com.icesoft.faces.webapp.http.servlet.SessionVerifier.service(SessionVerifier.java:26)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:131)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:56)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: javax.faces.event.AbortProcessingException: javax.el.ELException: /pages/monitorTest.jspx @23,64 valueChangeListener="#{monitorController.institutionChanged}": java.lang.NullPointerException
at javax.faces.event.MethodExpressionValueChangeListener.processValueChange(MethodExpressionValueChangeListener.java:48)
at javax.faces.event.ValueChangeEvent.processListener(ValueChangeEvent.java:59)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:489)
... 33 more
Caused by: javax.el.ELException: /pages/monitorTest.jspx @23,64 valueChangeListener="#{monitorController.institutionChanged}": java.lang.NullPointerException
at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:74)
at javax.faces.event.MethodExpressionValueChangeListener.processValueChange(MethodExpressionValueChangeListener.java:46)
... 35 more
Caused by: java.lang.NullPointerException
at com.vsoftcorp.watchmen.controller.MonitorController.createProgressBarList(MonitorController.java:94)
at com.vsoftcorp.watchmen.controller.MonitorController.institutionChanged(MonitorController.java:126)
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:597)
at org.apache.el.parser.AstValue.invoke(AstValue.java:172)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
... 36 more
 


Through the code-line Sstem.out.println("Creating ProgressBar List ====================>"); I have sure that until this point everything is ok, and I also have sure that my progressBarList and its DAO are ok, cause I tested the MODEL layer before start the integration with VIEW layer.

What should I do?

I downloaded the BIN like you said and deploy it without problem.

No WARNING any more :)

Thank you pandoo.

Hi everyone,

I`m trying to deploy my first MyFaces+IceFaces+Facelets webapp and then I noted the WARNING below during tomcat startup:
"WARNING: Push Server not found - the Push Server must be deployed to support multiple asynchronous applications."

After a few minutes researching at the forum, documentation and google I found, in brief words, that without deploy push-server app I can`t have more then one IceFaces app at same time like was suggested by the WARNING above.

To avoid future changes at my environment it`s better if I have push-server deployed at my container, so I tried to build the push-server.war as follow:
1 - went to the build.xml folder
cd /home/u9016/Libraries/IceFaces-1.8.2-src/icefaces/push-server

2- run ant command
ant -buildfile build.xml

Result:
BUILD FAILED
/home/u9016/Libraries/IceFaces-1.8.2-src/icefaces/push-server/build.xml:33: Compile failed; see the compiler error output for details.

How to see this "compiler error output"? Do I need to execute ant with another argument?

Attached follows my build.xml file used to build the push-server.war. Could anyone check if the file is correctly?
Note: I got this file at ICEfaces-1.8.2-src.zip which I just download from IceFaces homepage.

I would be really glad if some one send me the push-server.war, my mail is caio.formiga at gmail.com

Best Regards.

Oh man..THANK YOU A LOT...it worked...
I`m trying to deploy outputProgress-multiple-tutorial sample and what seams to be easy becomes a hard work between me, MyFaces impl, IceFaces, Facelets, .jspx, but in the end I won :P.

I have adapted the original sample to use Maven and after add icefaces-facelets-1.8.1.jar at pom.xml file Maven complains about el-api-1.1.11.jar. "Missing indirectly referenced artifact javax.el:el-api:jar:1.0:compile". So I added this dependency and Maven could successfully build the project.war.

The problem is, during Tomcat6.0.20 startup it throws this exception:
org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.apache.myfaces.webapp.StartupServletContextListener
java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.addELResolver(Ljavax/el/ELResolver;)V" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, org/apache/myfaces/webapp/Jsp21FacesInitializer, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ELResolver used in the signature
at org.apache.myfaces.webapp.Jsp21FacesInitializer.configureResolverForJSP(Jsp21FacesInitializer.java:114)

After reading a few tutorials and a lot of tests, I discovered that removing the el-api-1.1.11.jar problem is over.

Right now I just want to know if icefaces-facelets-1.8.1.jar depends of el-api-1.1.11.jar? Or Maven is crazy? Should I change icefaces-facelets version? Which one?

THANKS A LOT
Caio Formiga

 
Profile for caioformiga -> Messages posted by caioformiga [9]
Go to:   
Powered by JForum 2.1.7ice © JForum Team