[JBoss Seam] - Re: Trinidad PPR/Ajax and Seam
by dajevtic
Mainly I use the following class for consistent dialog handling for trinidad:
package de.livemediagroup.dialog;
|
| import java.util.Hashtable;
| import java.util.Map;
|
| import org.apache.myfaces.trinidad.context.RequestContext;
| import org.apache.myfaces.trinidad.event.ReturnEvent;
|
| public final class Dialog {
|
| public static final String CONFIRM = "confirm";
|
| public static final String CANCEL = "cancel";
|
| public static Map createReturnParameterMap() {
| return new Hashtable();
| }
|
| @SuppressWarnings("unchecked")
| public static void cancelDialog() {
| RequestContext.getCurrentInstance().returnFromDialog(CANCEL, createReturnParameterMap());
| }
|
| @SuppressWarnings("unchecked")
| public static void confirmDialog(Map returnParameters) {
| RequestContext.getCurrentInstance().returnFromDialog(CONFIRM, returnParameters);
| }
|
| public static boolean isConfirmed(ReturnEvent event) {
| Object returnValue = event.getReturnValue();
| return ((returnValue != null) && (returnValue.equals(CONFIRM)));
| }
|
| public static boolean isCanceled(ReturnEvent event) {
| Object returnValue = event.getReturnValue();
| return ((returnValue == null) || (returnValue.equals(CANCEL)));
| }
|
| }
|
when wanting to confirm a dialog i use the following code:
| public void saveUser() {
| Map returnParameters = Dialog.createReturnParameterMap();
| returnParameters.put("user", currentUserInformation);
| Dialog.confirmDialog(returnParameters);
| }
|
a return listener gets activated when returning from my dialog:
| public void processReturn(ReturnEvent event)
| throws AbortProcessingException {
| if (!Dialog.isCanceled(event)) {
| for (Object object : event.getReturnParameters().values()) {
| PersistableObject pObject = (PersistableObject) object;
| saveObject(pObject);
| getEntityManager().flush();
| }
| refresh();
| getNotifier().notifyDialogEnd();
| }
| clearHandledEntity();
| }
|
The snippet that activates the dialog, e.g.:
| <tr:commandLink id="editModeCommand" useWindow="true"
| returnListener="#{model.processReturn}" action="#{model.customize}">
| <f:param name="conversationPropagation" value="join"/>
| <h:graphicImage value="/images/gnome-settings.gif" />
| </tr:commandLink>
getNotifier is a simple, yet powerful goodie, because PPR updates can only occur on components that are below my triggering component. My Notifier is the first UI component so when I trigger it I can also PPR components which are before my commandLink that triggers the dialog.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4037388#4037388
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4037388
19 years
[JBoss Seam] - Re: Trinidad PPR/Ajax and Seam
by chane
I was using the bindings more because that was the example of how to use the dialogs with the Trinidad documentation.
If I didn't want to use bindings (which I don't really have a preference), how can I update the field on the calling page from the dialog selection. How do you use dialogs?
The use case is:
- open an edit screen (conversation start)
- fill in some information
- click an icon to popup a "lookup" window
- select a value - which fills in the value on the calling window
- fill in remaining info
- save button (persist objects / end conversation)
Right now we are using our home grown javascript to do the lookup. I thought we could replace it with the Trinidad dialog stuff - particularly since we are going to be using that component framework.
Chris....
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4037386#4037386
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4037386
19 years
[JBoss Seam] - Can't use FacesMessages.addToControl from Drools within Page
by knave_kilork
Hi
First, sorry for my bad english.
I'm getting some troubles with adding message to particular control on ajax4jsf-using page.
It looks like this. I click button on page, it use pageflow to run some drools, each of them can add messages to control (like validation), but messages appears as "global". I've watched FacesMessages code and found, what it calculates real clientId immidiately in call "add". In my scenario page on which i press "save" differ from that one what show messages, so it's wrong to calculate clientId in this manner. I changed FacesMessages to calculate clientId in beforeRenderResponce. But... I've found, what i have empty ajax component tree. I've made a little workaround, in cases, when calculated clientId is null, i pass key value as clientId, it solves problem for me, but seems to be a hack, because i need to pass calculated clientId as key to make it working.
What wrong in case of ajax-page? Why component tree is empty in renderResponce? Is it right, what clientId calculated immidiately in "add"?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4037383#4037383
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4037383
19 years