1 2 Previous Next 21 Replies Latest reply on Jul 4, 2006 6:26 AM by holgerprause

    DataModel / Duplicated ID

    marobashi

      Is a DataModel reusable / reloadable within a conversation?

      For example, my main page shows everyone's schedule for a given week, using a @DataModel (List). I have options to basically go forward and back (Next / Previous weeks) and the page bombs with a "Duplicated ID in faces tree" error.

      I just wanted to make sure that what I'm doing is conceptually sound. I am going to try a few things on this end (including trying the myFaces 1.0.9 suggestion listed in the previous post again).

      If this *should* conceptually work, I can post the relevant logs, code, etc.

      Thanks,
      Eric

        • 1. Re: DataModel / Duplicated ID
          gavin.king

          AFAIK, this is a known bug in MyFaces and/or facelets.

          • 2. Re: DataModel / Duplicated ID
            marobashi

            Thanks, Gavin. I'll give the 1.0.9 MyFaces a shot and see if it helps.

            • 3. Re: DataModel / Duplicated ID
              marobashi

              I updated (retrograded?) the version of myfaces in both the project build path and the server/default/deploy/jbossweb-tomcat55.sar/jsf-libs directory to version 1.0.9 and this problem has cleared up. I did want to mention some other things I noticed as a result of the change, though.

              1) My application works fine, though it's throwing a lot of variable resolver errors. (Variable xxx could not be resolved, thrown from VariableResolverImpl.) Just a warning at this point, and nothing *seems* to be broken...

              2) One of the properties of my User object is marked @NotNull... I am correctly receiving a "May not be null" message under myfaces 1.0.9. This is good. I believe I have been leaving that field blank while testing with 1.1, and the application was allowing me to do so without warning or error. Am I hallucinating, or have others had the same experience? The property is just a String, with getter method defined as follows:

              @Column(length=12)
              @NotNull
              @Length(max=12)
              public String getWah() {
               return wah;
              }
              


              Thanks for getting me straightened out and pointed somewhat closer to the right direction.

              • 4. Re: DataModel / Duplicated ID
                gavin.king

                 

                My application works fine, though it's throwing a lot of variable resolver errors. (Variable xxx could not be resolved, thrown from VariableResolverImpl.) Just a warning at this point, and nothing *seems* to be broken...


                Yes, this happens in some versions of MyFaces.

                • 5. Re: DataModel / Duplicated ID
                  drapierwim

                  I'm also stuck with the "duplicated in the faces tree" bug. So I was wondering is this solved in myfaces 1.1.1?

                  What version of myfaces is used by Seam(currently under CVS) and jboss 4.0.3 SP1?

                  If the bug is still in 1.1.1 can somebody post or mail me the link to download the 1.0.9 version.

                  Cheers :)

                  • 6. Re: DataModel / Duplicated ID
                    marobashi

                    Here's the link:

                    http://archive.apache.org/dist/myfaces/binaries/

                    I replaced the myfaces jars in my project's build path as well as in the JBoss AS (\server\default\deploy\jbossweb-tomcat55.sar\jsf-libs).

                    Perhaps I'll give 1.1.1 a shot if I get a spare minute here...

                    • 7. Re: DataModel / Duplicated ID
                      drapierwim

                      I've made some progress related to previuos post, this was done by upgrading(I think) to facelets-1.0.6 that cleared the duplicate id in faces tree bug.

                      I've also changed the myfaces jars to version 1.1.1 in the jboss4.0.3sp1/.../jsf-libs but that didn't change anything.

                      So I still don't have the required result, so some help is welcome.

                      My jsp page has a form used for add/edit/find and create a customer plus a
                      datatable for returning the result of a search, when I select a customer from my datatable for editing the form doesn't get filled and the datatable is rendered empty.

                      So here is the relevant code.

                      <h:form>
                      <fieldset>
                       <div>
                       Name:
                       <h:inputText value="#{customer.name}" />
                       </div>
                       <div>
                       Adress:
                       <h:inputText value="#{customer.adress.street}" />
                       </div>
                       <div>
                       Zip:
                       <h:inputText value="#{customer.adress.zip}" />
                       City:
                       <h:inputText value="#{customer.adress.city}" />
                       </div>
                       <h:commandButton value="Load all" action="#{customerManager.findAll}" />
                       <h:commandButton value="Search" action="#{customerManager.find}" />
                       <h:commandButton value="Save" action="#{customerManager.save}" />
                       <h:commandButton value="Cancel" action="#{customerManager.cancel}" />
                      </fieldset>
                      </h:form>
                      
                      <h:outputText value="No Customer Found" rendered="#{customers != null and empty customers}"/>
                      <h:dataTable id="customerstable"
                       value="#{customers}"
                       var="c">
                       <f:facet name="header" style="text-align: center;">
                       <h:outputText value="Customers" />
                       </f:facet>
                       <f:facet name="footer" rendered="#{customers.rowCount >= 1}">
                       <h:outputText value="Customers: #{customers.rowCount}" />
                       </f:facet>
                       <h:column>
                       <f:facet name="header">Name</f:facet>
                       <h:outputText value="#{c.name}" />
                       </h:column>
                       <h:column>
                       <f:facet name="header">Adress</f:facet>
                       <h:outputText value="#{c.adress.street}" />
                       </h:column>
                       <h:column>
                       <f:facet name="header">Zip</f:facet>
                       <h:outputText value="#{c.adress.zip}" />
                       </h:column>
                       <h:column>
                       <f:facet name="header">City</f:facet>
                       <h:outputText value="#{c.adress.city}" />
                       </h:column>
                       <h:column>
                       <h:commandLink value="edit" action="#{customerManager.edit}" />
                       </h:column>
                      </h:dataTable>


                      @Name("customerManager")
                      @Conversational(ifNotBegunOutcome="main")
                      @Interceptor(SeamInterceptor.class)
                      @Intercept(InterceptionType.ALWAYS)
                      @LoggedIn
                      public class CustomerManagerBean implements Serializable {
                      
                       private static final Logger logger = Logger.getLogger(CustomerManagerBean.class);
                      
                       @In(create=true)
                       private CustomerDAO customerDAO;
                      
                       @DataModel
                       private List<Customer> customers;
                       @DataModelSelectionIndex
                       private int customerIndex;
                      
                       @Out(required=false)
                       @In(required=false)
                       private Customer customer;
                      
                       private String searchString;
                      
                       @Create
                       public void create() {
                       logger.info("created");
                       }
                      
                       @Begin
                       public String find() {
                       logger.info("long running conversation begun");
                       return "customers";
                       }
                      
                       public String findAll() {
                       logger.info("loading all customers");
                       customers = customerDAO.findAll();
                       return "success";
                       }
                      
                       public String search() {
                       logger.info("find by example");
                       customers = customerDAO.findByExample(customer);
                       return null;
                       }
                      
                       public String edit() {
                       logger.info("edit customer: " + customerIndex);
                       if(customers == null) return "main";
                       setCustomer();
                       return "success";
                       }
                      
                       public String save() {
                       customerDAO.makePersistent(customer);
                       customers.add(customer);
                       logger.info("Conversation ended");
                       return "success";
                       }
                      
                       @End
                       public String cancel() {
                       logger.info("Conversation canceled");
                       return "main";
                       }
                      
                       private void setCustomer() {
                       customer = (Customer) customers.get(customerIndex);
                       logger.info(customerIndex + " -> " +
                       customer.getName());
                       }
                      
                       @Destroy
                       public void destroy() {
                       logger.info("destroyed");
                       }


                      When the edit link is pressesd I don't get the logging in the console from the customermanager like it can't be found.

                      • 8. Re: DataModel / Duplicated ID
                        marobashi

                        What does your faces-config.xml look like? Only reason I'm asking is that I see "success" as the result output of many of your methods... and which logging are you missing? The "Edit Customer:" one, the customer index / getname one, or both?

                        And stupid question here, but your interface bean *does* expose edit(), right?

                        I have very limited experience, but I'll try to help where and if I can...

                        • 9. Re: DataModel / Duplicated ID
                          drapierwim

                          The method findAll() works fine and fills the datatable, the String success is just for returning to the same page. As for my logging I get neither of them.

                          My CustomerManager is just a seam component, so an interface here is not needed.

                          I will try to experiment with null instead of returning a String since the myfaces 1.0.9 doesn't work also.

                          As for now my conclusion is that facelets is responsible for the duplicate id bug this can be resolved by upgrading to version 1.0.6

                          • 10. Re: DataModel / Duplicated ID
                            marobashi

                            Duh... I didn't even look at the top of your class at the implements statement... I just assumed you were coding based on the booking model, which uses one class for the interface and one bean for the backing actions.

                            Also, I don't know if this makes a difference, but I noticed your DataTable is defining a custom id. The example application doesn't do that, but I don't know enough about it to say whether or not it would have an effect. Maybe the custom id is interfering with Seam's ability to link the page variable back to the class? (Wild guess.)

                            Though that doesn't really explain why edit() appears not to have been called...

                            Perhaps more to the point, your commandlink doesn't quite match the example app... the example codes a command link like:

                            <h:commandLink action="#{allItinerariesByUser.selectItinerary}">Maintain Itinerary</h:commandLink>

                            ... and doesn't use that value= clause...

                            Again, shooting in the dark here.. not enough exp to know if these really matter.

                            • 11. Re: DataModel / Duplicated ID
                              gavin.king

                              None of those things should matter.

                              • 12. Re: DataModel / Duplicated ID
                                gavin.king

                                I have also had a lot of trouble with this issue.

                                One thing I noticed that seemed to make a difference was to use a non-null JSF outcome.

                                • 13. Re: DataModel / Duplicated ID
                                  gavin.king

                                  Yes, it does seem to fix the bug in all cases. You have to return an outcome and trigger a navigation rule from faces-config.xml.

                                  • 14. Re: DataModel / Duplicated ID
                                    g.tomassoni

                                     

                                    "gavin.king@jboss.com" wrote:
                                    Yes, it does seem to fix the bug in all cases. You have to return an outcome and trigger a navigation rule from faces-config.xml.


                                    I have this problem, too. But I don't (yet) have any interceptor triggered: I'm actually prototipizing a site and have only navigation links between pages (through <h:outputLink>). When I click on a link, sometimes I get the "_id0 duplicated" messages, which gets fixed simply by reloading the page in the browser.

                                    I have a two-level template nesting, however, which would cost me a bit to flatten. But I suspect that this may be the cause in my case.

                                    Did anybody of you experienced this problem with nested templates?

                                    Also, days are passed by the time of the last reply to this issue. So, I would like to know if there had been any advance in definitely fixing it.

                                    Thanks,

                                    1 2 Previous Next