[jboss-user] [JBoss Seam] - Re: Trinidad PPR/Ajax and Seam

dajevtic do-not-reply at jboss.com
Wed Dec 20 15:13:04 EST 2006


Hi Chane,
we used Seam and Trinidad in several of our POCs. No production applications yet, though.
I remember that we had to incorporate an additional phase listener along with an action listener configured in faces-config when using the dialog framework of Trinidad / ADF, because the conversation id was not propagated to the dialog. 
Otherwise, there are no known incompatibility issues.
We even use AJAX4JSF to "ajaxify" non-ajax components.

Here is the code to get dialogs of trinidad to work w/ seam:
PhaseListener:

  | 	private static final String CONVERSATION_ID_SESSION_PARAMETER = "conversationId";
  | 	
  | 	private Map createParameterMapForConversationRestore(String conversationId) {
  | 		Map paramterMap = new Hashtable();
  | 		paramterMap.put(CONVERSATION_ID_SESSION_PARAMETER, conversationId);
  | 		return paramterMap;
  | 	}
  | 	
  | 	private void restoreConversation(Context context) {
  | 		if (context.isSet(CONVERSATION_ID_SESSION_PARAMETER)) {
  | 			String convId = context.get(CONVERSATION_ID_SESSION_PARAMETER).toString();
  | 			Manager.instance().restoreConversation(createParameterMapForConversationRestore(convId));
  | 			context.remove(CONVERSATION_ID_SESSION_PARAMETER);		
  | 		}
  | 	}
  | 	
  | 	public void afterPhase(PhaseEvent event) {
  | 		try {
  | 			if (event.getPhaseId().equals(PhaseId.RESTORE_VIEW)) {
  | 				UIViewRoot root = event.getFacesContext().getViewRoot();
  | 				if (root != null) {
  | 					String viewId = root.getViewId();
  | 					if ((viewId != null) && viewId.endsWith("_dlg.jspx")) {
  | 						restoreConversation(Contexts.getSessionContext());
  | 					}
  | 				}
  | 			} else {
  | 				log.info("after " + event.getPhaseId());
  | 			}
  | 		} catch (Exception e) {
  | 			log.error("Could not restore Seam conversation", e);
  | 		}
  | 	}
  | 

Here is the code for the action listener:

  | 	public void processAction(ActionEvent actionEvent)
  | 			throws AbortProcessingException {
  | 
  | 		if (actionEvent.getComponent() instanceof CoreCommandLink) {
  | 			CoreCommandLink link = (CoreCommandLink)actionEvent.getComponent();
  | 			if (link.isUseWindow()) {
  | 				Contexts.getSessionContext().set("conversationId", Manager.instance().getCurrentConversationId());
  | 			}
  | 		}
  | 		super.processAction(actionEvent);
  | 	}
  | 
The example above assumes that popup dialogs end with a _dlg.jspx extensions, which you may alter to your desire.

Please remember, those were quick and dirty hacks in order to get conversations working with Trinidad.
This issue may have already been resolved, and if not there might be far better solutions.

Hope it helps.

Kind regareds,
dj

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3995439#3995439

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3995439



More information about the jboss-user mailing list