2 Replies Latest reply on Mar 1, 2011 1:52 AM by Andrej Zieger

    Url rewrite and different actions to execute for different patterns.

    Sergey Vidyuk Newbie

      I have one template which can be used for viewing, editing and creation of entities. In any use case it requires execution of some actions before rendering which loads some necessary data and those actions are different for view/edit mode and creation mode. With any use case URL should be restful.


      To satisfy those requirements I've created some funny but working kludge. I've created two additional files: create.xhtml and create.page.xml with the following content:


      <ui:include xmlns:ui="http://java.sun.com/jsf/facelets" src="view.xhtml"/>
      



      <?xml version="1.0" encoding="UTF-8"?>
      <page view-id="/courses/classes/create.xhtml">
         <action execute="#{classesViewer.initCreation}"/>
      </page>
      



      Right now I have some time for refactoring of this part of application and I want to do it in better way. Is it possible to have different actions for different patterns of the same view? Something like:


      <?xml version="1.0" encoding="UTF-8"?>
      <page view-id="/courses/classes/view.xhtml">
         <rewrite pattern="/courses/classes/view/{id}">
            <action execute="#{classesViewer.initView}"/>
         </rewrite>
         
         <rewrite pattern="/courses/classes/create">
            <action execute="#{classesViewer.initCreation}"/>
         </rewrite>
      </page>