6 Replies Latest reply on Dec 2, 2009 10:46 AM by Lavanya k

    Problem with Page Refresh

    Hari Dhanakoti Newbie

      Hi all,


      I had been working with the jboss seam. now i face a problem of page getting submitted whenever page is refreshed or F5 event is triggered.


      Can any one help me with how to overcome this problem.


      --
      Thanks


      Hari. D

        • 1. Re: Problem with Page Refresh
          Tom Goring Apprentice

          You can after processing your form use :


          <redirect/>



          so f5 will cause a HTTP GET.


          E.g.




             <navigation from-action="#{identity.login}">
                <rule if="#{identity.loggedIn}">
                   <redirect view-id="/home.xhtml"/>
                </rule>
                
             </navigation>


          • 2. Re: Problem with Page Refresh
            Hari Dhanakoti Newbie

            Thanks Tom,


            I faced a problem as such.


            I have a page with name and age field.


            In the first attempt I added up some value to the text box and the value is returned in the h:datatable. Once I get the result i try to refresh the page. The same data is getting inserted to the database.


            How to overcome this?

            • 3. Re: Problem with Page Refresh
              Tom Goring Apprentice

              redirect after you have processed ok the insert ?

              • 4. Re: Problem with Page Refresh
                Hari Dhanakoti Newbie

                Tom,


                  Can u please explain more how should be the flow with a sample.


                  Since i am new to jboss seam framework please let me know in clear.


                --
                Thanks
                Hari

                • 5. Re: Problem with Page Refresh
                  Tom Goring Apprentice

                  facelet (say mypage.xhtml):



                  <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                                        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                  <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                       xmlns:s="http://jboss.com/products/seam/taglib"
                       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:rich="http://richfaces.org/rich"
                       xmlns:jnet="http://jnet.ltd.uk/taglib"
                       xmlns:a="http://richfaces.org/a4j"
                       template="/layout/nosession.xhtml">
                  
                  
                  <ui:define name="body">
                      
                      <h:messages styleClass="message"/>
                      
                      <h:form id="login">
                        
                  ...
                  
                  <h:commandButton value="Update Details" action="#{userUpdater.update()}"/>
                  
                      </h:form>
                  
                   </ui:define> 
                  </ui:composition>




                  Backing Bean:



                  @Name(UserComponentNames.UserUpdater)
                  @Scope(ScopeType.CONVERSATION)
                  @PojoInterceptor
                  @Transactional
                  public class UserUpdaterBean implements Serializable {
                  ..
                     public String update() {
                  ..
                       return "success";
                     }
                  }
                  



                  pages.xml (mypage.page.xml):



                  <?xml version="1.0" encoding="UTF-8"?>
                  <page xmlns="http://jboss.com/products/seam/pages"
                       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                       xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd"
                       login-required="true" conversation-required="true" >
                  
                  <navigation from-action="#{userUpdater.update()}">
                    <rule if-outcome="success"           
                      <redirect/>
                    </rule> 
                  </navigation>
                  
                  </page>
                  
                  
                  
                  
                  
                  


                  • 6. Re: Problem with Page Refresh
                    Lavanya k Newbie

                    I have a similar issue with my dataTable. This datatable has a commandlink that invokes 'remove' modalPanel to delete the row for which the commandLink is clicked. In this modalPanel, when I click the 'Yes' button, the corresponding row values are removed from the local collection object that is bind with dataTable and from the database also.


                    There is a separate link below the dataTable that invokes 'add' modalPanelThe to insert new row in the dataTable. I am able to successfully add new row in the dataTable but not in the correct order. Thus when I tries to remove the record immediately after adding the record, the 'remove' modalPanel does not picks up the correct record. However when I refresh the page manually, the dataTable orders the rows correctly in the dataTable and then I am able to select and remove the correct record.


                    Please let me know how to reRender the dataTable after the server side insert action is completed or suggest me an alternate solution for this issue.


                    Thanks