voyent
Messages posted by: pandoo  XML
Profile for pandoo -> Messages posted by pandoo [69] Go to Page: 1, 2, 3, 4, 5 Next 
Author Message
I has been fixed for 1.8.3

Check out the source code:
icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\datapaginator\DataPaginator.java
this might be a known issue, have a look into the Icefaces Jira:

http://jira.icefaces.org/browse/ICE-5010
This is a known issue:

See and Vote for it:

http://jira.icefaces.org/browse/ICE-4998
...now it is more likely that there is a problem within your business logic.

if you want you could try to simplify your code and post it here or upload a .war example file!

good luck!
pandoo
Hi squick,

I wonder what is going to happen if your replace the ice:panelSeries with a c:foreach or an ui:repeat...Or even try to replace it with ice:dataTable JUST to indicate how it reacts with other (iterating) components

THX,
pandoo
You mustn't create an own RenderKit for that! Use Faclets :P

So you code would look like:

your main.xhtml view:
Code:
 <html xmlns="http://www.w3.org/1999/xhtml"
 	xmlns:ui="http://java.sun.com/jsf/facelets"
 	xmlns:f="http://java.sun.com/jsf/core"
 	xmlns:h="http://java.sun.com/jsf/html"
 	xmlns:ice="http://www.icesoft.com/icefaces/component">
     <head>
         <title>
 	        <ui:insert name="title">My Application</ui:insert>
         </title>
     </head>
     <body>
         <div id="menu">      	
 			<ice:form>
 				<ice:commandButton value="Suche"  action="#{controller.navigationSearch}"/>
 				<ice:commandButton value="Reports" />
 				<ice:commandButton value="Access"  />
 				<ice:commandButton value="Accessibility" action="#{controller.navigationAccessibility}" />
 			 </ice:form>
         </div>
          <div id="content">
   			 
   			 <ui:fragment rendered="#{controller.pageAccesibility == true}">
            		<ui:include src="/detailedSearch.jspx" />
 			</ui:fragment>
 			
 			 <ui:fragment rendered="#{controller.pageAccesibility == false}">
            		<ui:include src="/normalSearch.jspx" />
 			</ui:fragment>
 			
 			
 
 			<ui:fragment rendered="#{search.tableSearchResult.foundResult == true}">
 				<ui:include src="/tableResult.jspx" />
 			 </ui:fragment>
 			 
 			 <ui:fragment rendered="#{search.treeSearchResult.foundResult == true}">
            		<ui:include src="/treeResult.jspx" />>
 			 </ui:fragment>
          </div>
     </body>
 </html>
 


The Controller Bean:
Code:
 **
  * SESSION SCOPED
  */
 public class Controller {
 
 	private boolean pageAccesibility = false;
 
 	public Controller() {
 
 	}
 
 	// Called by an commandButton
 	public String navigationAccessibility() {
 		// set it to true will cause the JSF page to show certain (more)
 		// elements using the rendered attribute
 		setPageAccesibility(true);
 		// This is fine since we don't wan't to navigate to another page
 		return null;
 	}
 
 	// Called by an commandButton
 	public String navigationSearch() {
 		setPageAccesibility(false);
 		return null;
 	}
 
 	public void setPageAccesibility(boolean pageAccesibility) {
 		this.pageAccesibility = pageAccesibility;
 	}
 
 	public boolean isPageAccesibility() {
 		return pageAccesibility;
 	}
 
 }
 



You can download an example war file showing it more detailed:
https://www.wuala.com/pandoo/iceFaces/saabir.war?key=mx2PbG9ZHm0Y

Hi Phill,


When using SessionRenderer as you have done, will both their sessions be updated?
I want them to be updated independently - there are two separate search threads, and both of them will complete at different times.
 


If the Bean (lets call it searchBean) where the longRunning Method is being called is request or Session scoped both User will get different objects of that searchBean. So two different threads are up on a search call (in my example within the method startLongProcess)

Whenever a SessionRenderer.render("identifier_String") is being called ICEfaces will iterate through all the sessions that have been added to the the SessionRenderer with that particular identifier_String. Now if you've got two Users then there are two sessions registered in there. BUT! Icefaces will determine if the DOM of the Client really needs the get an update. Means if the Clients needs to retrieve the newest state change...Inf my example this would be the updated String Value of outputText. Sine the two Users have different LongRunning (remember it is session or request scoped) they've also got two different outputText objects whereas just one has changed it's internal state and thus just one Session (aka User aka Client) needs to retrieve that update.


Hi Phill,

Regarding your first question:
"can the Renderable be any request-scoped bean? " - Yes


And the second question:
" I only want to update one - the page the current user is looking at! "

(1) Using the SessionRenderer API:

SessionRenderer.addCurrentSession() will determine the current Session of the user and inform that session as soon as a SessionRenderer.render() method has been called. Inform means: Icefaces will check if the update is relevant for the current view where the user is and if not: We won't send anything back... But if so ICEfaces will check which parts of the domTree have changed and send the incremental change back to the client.

See my code example below:

Put the LongRunning into a request or session scope
Code:
 public class LongRunning {
 	private String outputText = "initalized";
 
 	public LongRunning() {
 		SessionRenderer.addCurrentSession("longRunningThread");
 	}
 
 	public void startLongProcess(ActionEvent event) {
 		setOutputText("started");
 
 		new Thread() {
 			public void run() {
 				try {
 					Thread.sleep(5000); // sleep for 5 seconds
 					setOutputText("stopped");
                                         //Inform all sessions that have been added to the SessionRenderer with that Name 'longRunningThread'
 					SessionRenderer.render("longRunningThread");
 				} catch (Exception e) {
 					System.err.println("Got caught sleeping on the job");
 				}
 			}
 		}.start();
 	}
 
 	public void setOutputText(String outputText) {
 		this.outputText = outputText;
 	}
 
 	public String getOutputText() {
 		return outputText;
 	}
 }
 


I hope this clarifies it a bit to you if not please don't hesitate to write back what confused you...

Regards,
pandoo
Hi,

You can easily create your own converterts in JSF. An general tutorial for converts can be found here:

http://facestutorials.icefaces.org/tutorial/converter-tutorial.html#customeconverters


Unfortunately there is a little bug, in order to get a custom DateConverter you need to extend from the 'DateTimeConverter' rather than just to implement the 'Converter' interface

(1) Create your own Converter
Code:
 public class XMLDateconverter extends DateTimeConverter {
 
 	/*
 	 * (non-Javadoc)
 	 * @see javax.faces.convert.DateTimeConverter#getAsObject(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String)
 	 */
 	public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
 		System.out.println("Debug0 Test: UI:     " + arg1);
 		System.out.println("Debug0 Test: String: " + arg2);
 		//Convert the String to an eg. XMLDate object
 
 		return YOUR_XMLDate_Object;
 	}
 
 	/*
 	 * (non-Javadoc)
 	 * @see javax.faces.convert.DateTimeConverter#getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
 	 */
 	public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
 		System.out.println("Debug1 Test: UI:     " + arg1);
 		System.out.println("Debug1 Test: String: " + arg2);
 		// You might not need to change that
 		return super.getAsString(arg0, arg1, arg2);
 	}
 }
 


(2) Define it in four faclet-conifg.xml
Code:
 	<converter>
 		<converter-id>xmlDateConverter</converter-id>
 		<converter-class>ch.mimacom.utils.XMLDateconverter</converter-class>
 	</converter>
 


(3) In your view page integrate your custom converter like:
Code:
          Date Picker:
 	<ice:selectInputDate >
 		<f:converter converterId="xmlDateConverter" />
 	</ice:selectInputDate>
 


I hope this is gonna help you, if not don't hesitate to write back...


Cheers,
pandoo
Salu GĂ©rald,

You did everything fine! Buuuut it might be that a tiny little thing is missing...

Could you try the following code, it worked in my case:

Code:
 <render-kit>
 	<render-kit-id>ICEfacesRenderKit</render-kit-id>
 	<render-kit-class>com.icesoft.faces.renderkit.D2DRenderKit</render-kit-class>
 	<renderer>
  		<component-family>javax.faces.Panel</component-family>
  		<renderer-type>com.icesoft.faces.Grid</renderer-type>
  		<renderer-class>com.asis.x2010.fmk.gui.tag.html.GridRenderer</renderer-class>
  	</renderer>
  	<renderer>
  		<component-family>javax.faces.Panel</component-family>
  		<renderer-type>javax.faces.Grid</renderer-type>
  		<renderer-class>com.asis.x2010.fmk.gui.tag.html.GridRenderer</renderer-class>
  	</renderer>
 </render-kit>
 


...as you can see I basically just added the two <render-kit-id> parameters!
Try this:


(1) I created a Session Scoped UserBean that contains the information on which territory the user is interested in.
Code:
 public class UserBean {
 
 	private String salesTerritoryId = "testID1";
 
 	public UserBean() {
 
 	}
 
 	public void setSalesTerritoryId(String salesTerritoryId) {
 		this.salesTerritoryId = salesTerritoryId;
 	}
 
 	public String getSalesTerritoryId() {
 		return salesTerritoryId;
 	}
 
 }
 
 


(2) We are injecting the UserBean (JSF -> faces-config.xml) into the JMSPopup Bean
Code:
 public class JMSPopup implements Renderable, DisposableBean {
 	private UserBean userBean;
 	private JMSMessageCentreBean jmsMessageCentreBean;
 	private String stringMessage;
 	private boolean showPopup;
 
 	private PersistentFacesState state;
 
 	public JMSPopup() {
 		state = PersistentFacesState.getInstance();
 	}
 
 	public void showMessage(String message) {
 		this.showPopup = true;
 		this.stringMessage = message;
 	}
 
 	public void closeMessage() {
 		this.showPopup = false;
 		this.stringMessage = null;
 	}
 
 	public PersistentFacesState getState() {
 		return state;
 	}
 
 	public void setJmsMessageCentreBean(
 			JMSMessageCentreBean jmsMessageCentreBean) {
 		this.jmsMessageCentreBean = jmsMessageCentreBean;
 	}
 
 	public JMSMessageCentreBean getJmsMessageCentreBean() {
 		return jmsMessageCentreBean;
 	}
 
 	public void renderingException(RenderingException arg0) {
 		this.jmsMessageCentreBean.deRegisterPopup(this);
 	}
 
 	public void dispose() throws Exception {
 		this.jmsMessageCentreBean.deRegisterPopup(this);
 	}
 
 	public String getStringMessage() {
 		return stringMessage;
 	}
 
 	public void setStringMessage(String stringMessage) {
 		this.stringMessage = stringMessage;
 	}
 
 	public boolean isShowPopup() {
 		return showPopup;
 	}
 
 	public void setShowPopup(boolean showPopup) {
 		this.showPopup = showPopup;
 	}
 
 	public void setUserBean(UserBean userBean) {
 		this.userBean = userBean;
 		if (jmsMessageCentreBean != null) {
 			this.jmsMessageCentreBean.registerPopup(this);
 		}
 	}
 
 	public UserBean getUserBean() {
 		return userBean;
 	}
 
 }
 
 
 


(3) Instead of just having a single OnDemandRenderer we create for every different territory an new one.

Next a Popup registers itself and is added to the corresponding OnDemandRenderer with the territoryID of the userBean object that the popup is holding.

Next we iterate through all the JMSPopupBeans but only change the state of those that have the requested territoryID.

Next we get the corresponding OnDemandRenderer with that requested territoryID and finally invoke the ICEfaces Push call.

Code:
 public class JMSMessageCentreBean {
 
 	private RenderManager renderManager;
 	private Vector<JMSPopup> renderableBeans = new Vector<JMSPopup>();
 
 	private static final String GROUP_Name = "JMS_";
 
 	private String salesTerritoryId = "testID1";
 
 	// This is a application scoped bean
 	public JMSMessageCentreBean() {
 
 	}
 
 	public void sendMessage() {
 		final String territory = salesTerritoryId;
 		final String message = "ICEfaces ruullez";
 
 		// Iterate through the list and only get the ones with the specified
 		// territory id;
 		for (JMSPopup popup : renderableBeans) {
 			if (popup.getUserBean().getSalesTerritoryId().equals(territory)) {
 				popup.showMessage(message);
 			}
 		}
 
 		final OnDemandRenderer aOnDemandRenderer = getGroupedOnDemandRenderer(territory);
 		aOnDemandRenderer.requestRender();
 
 		// Popup closing Thread
 		new Thread() {
 			public void run() {
 				try {
 					// sleep for 5 seconds
 					Thread.sleep(5000);
 					for (JMSPopup popup : renderableBeans) {
 						if (popup.getUserBean().getSalesTerritoryId().equals(territory)) {
 							popup.closeMessage();
 						}
 					}
 					aOnDemandRenderer.requestRender();
 				} catch (Exception e) {
 					System.err.println("Got caught sleeping on the job");
 				}
 			}
 		}.start();
 
 	}
 
 	public void registerPopup(JMSPopup popup) {
 		System.out.println("Registered Popup: " + popup);
 		renderableBeans.add(popup);
 
 		OnDemandRenderer aOnDemandRenderer = getGroupedOnDemandRenderer(popup
 				.getUserBean().getSalesTerritoryId());
 		aOnDemandRenderer.add(popup);
 	}
 
 	/**
 	 * Returns only the OnDemandRenderer for the specified territoryId: 

 	 * Example: JMS_territoryId1
 	 * 
 	 * @param territoryId
 	 * @return
 	 */
 	private OnDemandRenderer getGroupedOnDemandRenderer(String territoryId) {
 		OnDemandRenderer aOnDemandRenderer = renderManager
 				.getOnDemandRenderer(GROUP_Name + "territoryId");
 		return aOnDemandRenderer;
 	}
 
 	public void deRegisterPopup(JMSPopup popup) {
 		renderableBeans.remove(popup);
 		OnDemandRenderer aOnDemandRenderer = getGroupedOnDemandRenderer(popup
 				.getUserBean().getSalesTerritoryId());
 		aOnDemandRenderer.remove(popup);
 	}
 
 	public void setRenderManager(RenderManager renderManager) {
 		// Injected renderManager (injected by JSF)
 		this.renderManager = renderManager;
 
 	}
 
 	public void setSalesTerritoryId(String salesTerritoryId) {
 		this.salesTerritoryId = salesTerritoryId;
 	}
 
 	public String getSalesTerritoryId() {
 		return salesTerritoryId;
 	}
 }
 


faces-config.xml
Code:
 <managed-bean>
 		<managed-bean-name>jmsPopup</managed-bean-name>
 		<managed-bean-class>ch.mimacom.JMSPopup</managed-bean-class>
 		<managed-bean-scope>request</managed-bean-scope>
 		<managed-property>
 			<property-name>jmsMessageCentreBean</property-name>
 			<property-class>ch.mimacom.JMSMessageCentreBean</property-class>
 			<value>#{jmsMessageCentreBean}</value>
 		</managed-property>
 		<managed-property>
 			<property-name>userBean</property-name>
 			<property-class>ch.mimacom.UserBean</property-class>
 			<value>#{userBean}</value>
 		</managed-property>
 </managed-bean>
 
There has been a bug in ICEfaces 1.7.2 where as each ice:outputResource has been the same within a dataTable.

See: http://jira.icefaces.org/browse/ICE-3711

Which version are you using?
* 1.7.2 SP1 (fixed)
* 1.7.2 SP2
* 1.8.1
* 1.8.2

If you are using a never one than 1.7.2 SP1 please attach your backing bean code and the JSPX/XHTML code...


thanks,
pandoo

The push-server.war file is directly included within the BIN(ary) download of you iceFaces release.

Check out here:
http://www.icefaces.org/main/downloads/os-downloads.iface


It is extremely easy ti integrate: Just deploy it together with your other ICEfaces applications. Thats it!

Greez,
pandoo
If you're able to reproduce that problem everytime I'd appreaciate if you could provide your:

* JSPX/XHTML code
* Backing Bean Code

Thank you,
pandoo
Unfortunately I don't have an idea how you could trigger a javaScript call on all the renderable beans, since you'd need to get their individual FacesContext which is not possible....

Anyway, don't make use of that bloody JavaScript! =) Use the lovely components provided by ICEfaces such as PanelPopup!

Thus it gets very easy to do:

(1) Create a Appliaction scoped Bean (JMSMessageCentreBean). I've never used JMS so far, but I think you should be able to kinda retrieve that JMSMessageCentreBean in your JMS business logic and call the 'sendMessage()' method somehow. OR instead you could integrate the JMS Stuff directly into the Bean (JMSMessageCentreBean)....
Code:
 import java.util.Vector;
 import com.icesoft.faces.async.render.OnDemandRenderer;
 import com.icesoft.faces.async.render.RenderManager;
 
 public class JMSMessageCentreBean {
 
 	private RenderManager renderManager;
 	private OnDemandRenderer onDemandRenderer;
 	private Vector<JMSPopup> renderableBeans = new Vector<JMSPopup>();
 
 	// This is a application scoped bean
 	public JMSMessageCentreBean() {
 
 	}
 
 	public void sendMessage() {
 		String message = "ICEfaces ruullez";
 
 		// Show all the Popups with the JMS Message
 		for (JMSPopup popup : renderableBeans) {
 			popup.showMessage(message);
 		}
                 //invoke ICEfaces Push Call
                 onDemandRenderer.requestRender();
 
 		// Popup closing Thread
 		new Thread() {
 			public void run() {
 				try {
 					// sleep for 5 seconds
 					Thread.sleep(5000);
 					for (JMSPopup popup : renderableBeans) {
 						popup.closeMessage();
 					}
                                         //invoke ICEfaces Push Call
 					onDemandRenderer.requestRender();
 				} catch (Exception e) {
 					System.err.println("Got caught sleeping on the job");
 				}
 			}
 		}.start();
 
 	}
 
 	public void registerPopup(JMSPopup popup) {
 		System.out.println("Registered Popup: " + popup);
 		renderableBeans.add(popup);
 		onDemandRenderer.add(popup);
 	}
 
 	public void deRegisterPopup(JMSPopup popup) {
 		renderableBeans.remove(popup);
 		onDemandRenderer.remove(popup);
 	}
 
 	public void setRenderManager(RenderManager renderManager) {
 		// Injected renderManager (injected by JSF)
 		this.renderManager = renderManager;
 		this.onDemandRenderer = renderManager
 				.getOnDemandRenderer("jmsMessageCentre");
 	}
 }
 


(2) Next create a request Scoped Bean (JMSPopup).
Code:
 import com.icesoft.faces.async.render.Renderable;
 import com.icesoft.faces.context.DisposableBean;
 import com.icesoft.faces.webapp.xmlhttp.PersistentFacesState;
 import com.icesoft.faces.webapp.xmlhttp.RenderingException;
 
 public class JMSPopup implements Renderable, DisposableBean {
 	private JMSMessageCentreBean jmsMessageCentreBean;
 	private String stringMessage;
 	private boolean showPopup;
 
 	private PersistentFacesState state;
 
 	public JMSPopup() {
 		state = PersistentFacesState.getInstance();
 	}
 
 	public void showMessage(String message) {
 		this.showPopup = true;
 		this.stringMessage = message;
 	}
 
 	public void closeMessage() {
 		this.showPopup = false;
 		this.stringMessage = null;
 	}
 
 	public PersistentFacesState getState() {
 		return state;
 	}
 
 	public void setJmsMessageCentreBean(
 			JMSMessageCentreBean jmsMessageCentreBean) {
 		this.jmsMessageCentreBean = jmsMessageCentreBean;
 		this.jmsMessageCentreBean.registerPopup(this);
 	}
 
 	public JMSMessageCentreBean getJmsMessageCentreBean() {
 		return jmsMessageCentreBean;
 	}
 
 	public void renderingException(RenderingException arg0) {
 		this.jmsMessageCentreBean.deRegisterPopup(this);
 	}
 
 	public void dispose() throws Exception {
 		this.jmsMessageCentreBean.deRegisterPopup(this);
 	}
 
 	public String getStringMessage() {
 		return stringMessage;
 	}
 
 	public void setStringMessage(String stringMessage) {
 		this.stringMessage = stringMessage;
 	}
 
 	public boolean isShowPopup() {
 		return showPopup;
 	}
 
 	public void setShowPopup(boolean showPopup) {
 		this.showPopup = showPopup;
 	}
 }
 


(3) Here is the faces-config.xml code:
Code:
 <faces-config
     xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
     version="1.2">
 	<application>
 		<view-handler>com.icesoft.faces.facelets.D2DFaceletViewHandler</view-handler>
 	</application>
 	<managed-bean>
 		<managed-bean-name>jmsMessageCentreBean</managed-bean-name>
 		<managed-bean-class>ch.mimacom.JMSMessageCentreBean</managed-bean-class>
 		<managed-bean-scope>application</managed-bean-scope>
 		<managed-property>
 			<property-name>renderManager</property-name>
 			<property-class>com.icesoft.faces.async.render.RenderManager</property-class>
 			<value>#{renderManager}</value>
 		</managed-property>
 	</managed-bean>
 	<managed-bean>
 		<managed-bean-name>jmsPopup</managed-bean-name>
 		<managed-bean-class>ch.mimacom.JMSPopup</managed-bean-class>
 		<managed-bean-scope>request</managed-bean-scope>
 		<managed-property>
 			<property-name>jmsMessageCentreBean</property-name>
 			<property-class>ch.mimacom.JMSMessageCentreBean</property-class>
 			<value>#{jmsMessageCentreBean}</value>
 		</managed-property>
 	</managed-bean>
 	<managed-bean>
 		<managed-bean-name>renderManager</managed-bean-name>
 		<managed-bean-class>com.icesoft.faces.async.render.RenderManager</managed-bean-class>
 		<managed-bean-scope>application</managed-bean-scope>
 	</managed-bean>
 </faces-config>
 


(4) in all of your views integrate the following code snippet:
(if your using faclets it is recommended to extract it into a own code file and integrate it using the include tag)


<ice:form>
<ice:panelPopup id="modalPnlPop" draggable="false" modal="true"
visible="#{jmsPopup.showPopup}" autoCentre="true">
<f:facet name="header">
<ice:panelGroup styleClass="popupHeaderWrapper">
<ice:outputText value="JMS Message" />
</ice:panelGroup>
</f:facet>
<f:facet name="body">
<ice:panelGroup styleClass="popupBody">
<ice:outputText value="#{jmsPopup.stringMessage}" />
</ice:panelGroup>
</f:facet>
</ice:panelPopup>
</ice:form>
 
 
Profile for pandoo -> Messages posted by pandoo [69] Go to Page: 1, 2, 3, 4, 5 Next 
Go to:   
Powered by JForum 2.1.7ice © JForum Team