0 Replies Latest reply on Jun 27, 2008 10:34 PM by Alejandro Pérez

    Navigation Rule problem

    Alejandro Pérez Newbie

      I need to display a confirmation when try to delete an entity. I use Remoting and work fine, I need to redirect to another page after the acction but the rule not work.
      Can any body help me? thanks in advance.


      this is my code:


      user.xhtml page:



      ....   
      <script type="text/javascript" src="seam/resource/remoting/resource/remote.js"></script>
      <script type="text/javascript" src="seam/resource/remoting/interface.js?userEraser"></script>       
      <s:remote include="userEraser" />
              
      <script type="text/javascript">
       //<![CDATA[
       function confirmRemove(id, name) {
          if (confirm("Seguro que desea eliminar el usuario "+name+"?")) {
                              Seam.Component.getInstance("userEraser").remove(id);
                      }
              }
       // ]]>
      </script>
      ....
      <h:commandButton id="delete" value="Eliminar" 
                                  onclick="javascript:confirmRemove('#{userHome.instance.id}', '#{userHome.instance.name}');"
                                  rendered="#{userHome.managed}"/>
      ....




      UserEraser.java:



      @Local
      public interface UserEraser {  
          
              @WebRemote
              public void remove(Long id);  
      }




      UserEraserBean.java



      @Stateless
      @Name("userEraser")
      public class UserEraserBean implements UserEraser {
              
          @Logger private Log log;
              
          @In FacesMessages facesMessages;
          
          @PersistenceContext
          EntityManager entityManager;    
          
          public void remove(Long id)
          {
              User user = entityManager.find(User.class, id);
              entityManager.remove(user);        
              
              log.info("userEraser.remove() action called");
              facesMessages.add("remove");
          }
          
      }




      pages.xml



          <page view-id="/user.xhtml">
                      <navigation from-action="#{userEraser.remove}">
                              <rule>
                                      <render view-id="/userList.xhtml" />
                              </rule>
                      </navigation>    
          </page>