1 2 3 4 Previous Next 46 Replies Latest reply on Nov 13, 2007 12:29 PM by pmuir Go to original post
      • 15. Re: Trinidad PPR/Ajax and Seam
        dajevtic

        Hi Chane.
        Try adding @Scope(ScopeType.CONVERSATION) to the class.
        That should do the trick.
        If not let me know and I'll try your code myself.

        Regards,
        dj

        • 16. Re: Trinidad PPR/Ajax and Seam


          I'm pretty sure the Conversation scope is added to Stateful components automatically. Anyway, I added it explicitly to see if that had any affect and I still get the same error.

          Maybe I should back up a step and prepare a simple application that I could upload so that people could take a look. We could then work off of a common sample.

          Chris....

          • 17. Re: Trinidad PPR/Ajax and Seam

            ok - I put together a sample application that can be downloaded here:

            http://sourceforge.net/project/showfiles.php?group_id=189858&package_id=228602&release_id=500974

            This is an eclipse 3.1 project that is ready to go. Download the file, create the project in eclipse, change the build-properties for your jboss directory and then run the ant target "deploy".

            Navigate to http://localhost:8080/testApp. The main page will be displayed, click the button "Start dialog" and you will get the error in the jboss server window that I list previously in the thread.

            Any ideas on what to do next or how I have misconfigued would be appreciated. Also, the only thing I left out was the custom ActionListener (but I don't think that is the cause of this error).

            Thanks for any help,
            Chris....

            • 18. Re: Trinidad PPR/Ajax and Seam

              dj - thanks for your help and writing the code you posted very early in this discussion. I finally got it to work.

              The trick is that the component that is the target for the binding element on the <tr:inputText binding="#{dialogManager.input}".../> can not be a Conversation Scoped Component. Once I took off the @Stateful annotation and just had @Name, everything started to fall into place.

              And a big thanks to cbauer. I finally figured this out by reading a comment he put on the example wiki UIBinding component about bindings not working with @In or conversation scoped components.

              Thanks,
              Chris....

              • 19. Re: Trinidad PPR/Ajax and Seam
                dajevtic

                chane,
                I'm glad you got it sorted out.
                However, you might want to consider not using bindings at all. To me they are actually the most useless feature of JSF...
                I actually didn't quite figure out why you are using the bindings at all?!

                • 20. Re: Trinidad PPR/Ajax and Seam


                  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....

                  • 21. Re: Trinidad PPR/Ajax and Seam
                    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.


                    • 22. Re: Trinidad PPR/Ajax and Seam

                      Chris, I am also having problems getting dialogs to work with Seam, could you post a working example since you seem to have gotten it working? It would really help to see all the pieces together in one place.

                      Thanks

                      • 23. Re: Trinidad PPR/Ajax and Seam

                        I don't have a sample I can post. But I'll help you through it if I can. There might even be a better way. Here's what I did/know:

                        1) I used the classes dajevtic posted at the start of this thread.

                        - The ActionListener needs to be a subclass of the one provided by MyFaces or the Sun RI. If you know another way to plug-in an ActionListener, let me know.

                        - The PhaseListener is a new class

                        - Also, I changed the conversationID to be cid (which I believe is what 2.1.0 is using now)

                        2) Actually, that's pretty much it. The only other thing is: Do not use the "binding" attribute on any components. If you do, this (and a lot of other stuff) will not work. What I do is something like the following:

                        Component on xhtml (facelets) page:

                         <tr:inputText value="#{backingBean.attribute}"
                         readOnly="true"
                         partialTriggers="dialog_id"/>
                         <tr:commandLink action="#{backingBean.launch}"
                         partialSubmit="true"
                         useWindow="true"
                         windowWidth="400" windowHeight="400"
                         returnListener="#{backingBean.return}"
                         id="dialog_id">


                        Backing Bean:
                         public String launch(){
                         return "dialog:pageName";
                         }
                        
                         public void returnProduct(ReturnEvent event){
                         bean.setProperty((String)event.getReturnValue());
                         }


                        And then you need a faces-config.xml navigation entry (I have not tried this in pages.xml yet):
                         <navigation-rule>
                         <from-view-id>/*</from-view-id>
                        
                         <navigation-case>
                         <from-outcome>dialog:pageName</from-outcome>
                         <to-view-id>/path/page_dlg.its</to-view-id>
                         </navigation-case>
                         <navigation-rule>


                        Let me now if this works for you,
                        Chris....

                        • 24. Re: Trinidad PPR/Ajax and Seam

                          Thanks Chris, I have it most of the way working except for a couple of issues.

                          1. When i use a commandLink to open the dialog, I can't get PPR to refresh the inputText on the orginal page. I keep getting this message

                          ERROR [STDERR] May 1, 2007 9:11:57 AM org.apache.myfaces.trinidadinternal.renderkit.core.ppr.PPRResponseWriter$PPRTag finish
                          WARNING: No PPR-capable id found for elements of CoreInputText[UIXEditableFacesBeanImpl, id=customer_input]. This component has not written-out an id attribute.


                          customer_input is the inputText I wish to pass the value from the dialog back to.

                          Here is the relevant part of the page
                          <tr:inputText id="customer_input"
                           value="(Empty)"
                           label="Enter New Customer:"
                           partialTriggers="dialog_id"/>
                          <s:conversationPropagation>
                           <tr:commandLink id="dialog_id"
                           text="find Customer"
                           action="dialog:chooseCustomer"
                           useWindow="true" windowHeight="400"
                           windowWidth="400" partialSubmit="true"/>
                          </s:conversationPropagation>


                          2. When I use a tr:inputListOfValues component instead (it encapsulates all the functionality I need) the object I hand back to the page is getting its toString method called instead of correctly referencing a property of the object

                          <tr:inputListOfValues returnListener="#{requestEntry.processReturn}"
                           id="customer_input"
                           label="Enter New Customer:"
                           value="#{requestEntry.customer.userName}"
                           action="dialog:chooseCustomer"/>


                          The userName property is not being referenced at all and instead the toString method of the customer object is being called instead. It really makes no sense. I have outputed the customer object's properties to the console during the ActionEvent of the dialog and again during ReturnListener of the calling form so I know the object is being passed correctly, its just the value property of the inputListOfValues is being weird.

                          Thanks for any help.

                          • 25. Re: Trinidad PPR/Ajax and Seam

                             

                            "smithbstl" wrote:
                            Thanks Chris, I have it most of the way working except for a couple of issues.

                            1. When i use a commandLink to open the dialog, I can't get PPR to refresh the inputText on the orginal page. I keep getting this message

                            ERROR [STDERR] May 1, 2007 9:11:57 AM org.apache.myfaces.trinidadinternal.renderkit.core.ppr.PPRResponseWriter$PPRTag finish
                            WARNING: No PPR-capable id found for elements of CoreInputText[UIXEditableFacesBeanImpl, id=customer_input]. This component has not written-out an id attribute.


                            customer_input is the inputText I wish to pass the value from the dialog back to.

                            Here is the relevant part of the page
                            <tr:inputText id="customer_input"
                             value="(Empty)"
                             label="Enter New Customer:"
                             partialTriggers="dialog_id"/>
                            <s:conversationPropagation>
                             <tr:commandLink id="dialog_id"
                             text="find Customer"
                             action="dialog:chooseCustomer"
                             useWindow="true" windowHeight="400"
                             windowWidth="400" partialSubmit="true"/>
                            </s:conversationPropagation>



                            I use a returnListener on my command link. That is what sets the value on my backing bean. I then have the backing bean provide the value to the input box. That might be it? If there isn't a backing bean on the value, how is the framework going to know what to update (also, don't using the binding attribute on inputbox - will not work - there is another thread talking about this).

                            As for the error, I don't know. You might ask on the trinidad list (which is now the myfaces list since it got "promoted").

                            Also, I have not used the <s:conversationPropagation/> tag. If you use this, does it mean you don't have to have the custom ActionListener and PhaseListener?

                            "smithbstl" wrote:

                            2. When I use a tr:inputListOfValues component instead (it encapsulates all the functionality I need) the object I hand back to the page is getting its toString method called instead of correctly referencing a property of the object

                            <tr:inputListOfValues returnListener="#{requestEntry.processReturn}"
                             id="customer_input"
                             label="Enter New Customer:"
                             value="#{requestEntry.customer.userName}"
                             action="dialog:chooseCustomer"/>


                            The userName property is not being referenced at all and instead the toString method of the customer object is being called instead. It really makes no sense. I have outputed the customer object's properties to the console during the ActionEvent of the dialog and again during ReturnListener of the calling form so I know the object is being passed correctly, its just the value property of the inputListOfValues is being weird.


                            hmmm...that does sound strange. I would ask on the Trinidad list. I tried to use inputListOfValues also but ran into problems trying to make it readonly so I gave up trying to use it for now. Altough, it almost sounds like it is a Seam issue and can not find the properties correctly. Can you get the "userName" by using <h:inputText>?

                            Wish I could help more. If you figure it out, you might post here so others trying to do something similar can learn from your efforts.

                            Chris....

                            • 26. Re: Trinidad PPR/Ajax and Seam

                              Thanks Chris, I have a return listener already which is functioning correctly, just not the PPR to refresh the page

                              public void processReturn(ReturnEvent event) {
                               if (event.getReturnValue() != null) {
                               //setUserName(((User)(event.getReturnValue())).getUserName());
                               customer = ((User)(event.getReturnValue()));
                               System.out.println("*******Return Event");
                               System.out.println("User Name: " + customer.getUserName());
                               }
                               }


                              As far as the s:conversationPropagation tag, yeah, thats kind of what I am attempting, no definitive results yet since I can't get the whole thing working with the custom PhaseListener/ActionListener.

                              I think I may steer clear of the inputListOfValues since it hides a little too much magic. The inputListOfValues code from my previous post is blowing up because customer is null when the page loads (NPE).

                              If I have any luck I will post back here.

                              ps - I made a post to the Trinidad List but no responses yet, I don't know if everying is using the new list yet (users@myfaces.apache.org). I am afraid more posts will get overlooked since that list services Myfaces, Tomahawk, Tobago, and now Trinidad....ugh

                              • 27. Re: Trinidad PPR/Ajax and Seam
                                dajevtic

                                Hi. Have you ever tried placing your to-be-updated tags into a panelGroupLayout or panelLabelAndMessage?

                                I use inputListOfValues for either inputting or selecting a postal code from a list of values and upon selection i update the calling page's fields with city and country info. It all works perfectly fine:

                                <tr:inputListOfValues id="postalcode" action="dialog:citieslov" valueChangeListener="#{valueChangeHandler.processPostalCodeChange}"
                                 label="#{messages.postalcode}:" autoSubmit="true" showRequired="true" partialTriggers="postalcode" value="#{currentCompany.city.postalcode}"
                                 returnListener="#{valueChangeHandler.processReturnCityToCompanyLov}">
                                 <f:param name="conversationPropagation" value="join" />
                                 </tr:inputListOfValues>
                                
                                 <tr:panelLabelAndMessage label="#{messages.city}:">
                                 <tr:outputText partialTriggers="postalcode" id="city"
                                 value="#{currentCompany.city.name}" />
                                 </tr:panelLabelAndMessage>


                                • 28. Re: Trinidad PPR/Ajax and Seam

                                  I will try your suggestion dajevtic, thanks

                                  A couple of questions,

                                  1. Are you still using the code you provided earlier in the thread (Phase Listener and Action Listener)? I know those comments are a number of months old and didn't if anything on either Seam or Trinidad was "fixed" to make them unecessary.

                                  2. Which view handler are you using in web.xml?
                                  - com.sun.facelets.FaceletViewHandler?
                                  - org.jboss.seam.ui.facelet.SeamFaceletViewHandler?

                                  Does it make a difference when it comes to Trinidad Dialogs (or anything else Trinidad related such as PPR)?

                                  Thanks

                                  -Brian

                                  • 29. Re: Trinidad PPR/Ajax and Seam
                                    dajevtic

                                    Hi, yes I still use the phase- and action listeners, but to be honest, I haven't tested in months, whether it works without them.

                                    I've beem using the SeamFaceletViewHandler since I switched to Facelets some weeks ago.

                                    If my solution doesn't work, then let me know. I'll provide more info.