Announcement Announcement Module
Collapse
No announcement yet.
Rest Uris with swf Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rest Uris with swf

    Hello, I have two questions regarding rest urls for flow.

    First I look up for uri templates and didn't find a (easy) way to do it.
    Then I thought of using query parameters instead of a uri template but they seem to get lost when flows start, eventhough I can read them on flow start I would like them to be present on the redirected url.

    So the questions are:

    1) Is it possible to use a uri template for web flow urls, such as order/1/edit? (As I said, I searched a little and I think it is not)

    2) Is correct for the DefaultFlowUrlHandler to not use the query parameters on redirecting when new flows are started (createFlowExecutionUrl(...) implementation),
    such as in .../order?edit=1 being redirected to order?execution=eXsY. I know the execution param is needed, but should the original parameters be removed?

    Thank in advance.

  • #2
    Hi there,

    Just wondering why you would want RESTful URLs for your flowExecutionURLs? It doesn't seem a good fit to me...

    Paul

    Comment


    • #3
      Maybe it's not a good fit as you say.

      For example,
      I would like to have a url for listing books (html) such as .../book/list;
      and from there I would like to be able to edit a particular book (html) in a url such as /book/{id}/edit or .../book?edit_id={id}.
      And in the server maybe I would have some controller to POST the edited data of the html pages.
      From the flow perpective, that would require to lunch a subflow in a transition to navigate to the edition page passing the correct identifier of the book. From what I have read, it seems that you can't have the parameters passed in the url of the flow as I intend.

      In conclusion, as you say Paul, it seems that the server-centric state saving of web flow and the REST-style URLs don't seem to fit together, at least for the current version of web flow.
      Thanks for the answer!!

      Comment


      • #4
        Hi!
        May be you can use Flow Handlers for this.
        Code:
        import org.springframework.webflow.core.collection.LocalAttributeMap;
        import org.springframework.webflow.core.collection.MutableAttributeMap;
        import org.springframework.webflow.mvc.servlet.AbstractFlowHandler;
        
        public class UpdateProductFlowHandler extends AbstractFlowHandler {
        
        	@Override
        	public String getFlowId() {
        		/*
        		 * Returns the id of the flow handled by this handler.
        		 */
        		return "updateProduct";
        	}
        
        	@Override
        	public MutableAttributeMap createExecutionInputMap(HttpServletRequest request) {
        		LocalAttributeMap attributeMap = new LocalAttributeMap();
        		/*
        		 * Parse request attributes here and add them to attributeMap.
        		 */
        		return attributeMap;
        	}
        	
        }
        and in springDispatcher-servlet.xml:
        Code:
        <bean name="updateProduct" class="your.package.UpdateProductFlowHandler" />
        
        <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        	<property name="mappings">
        		<map>
        			<entry key="/product/*/edit.do" value-ref="updateProduct" />
        		</map>
        	</property>
        </bean>
        Last edited by presence; Sep 27th, 2011, 04:33 AM.

        Comment


        • #5
          Yes that looks like it could work, but I think when starting the flow, a redirect will be send to the browser, and the url will change
          from .../producto/4/edit.do
          to .../updateProduct.
          But I didn't tried really, I will see if I can make some time to investigate that solution.
          For now the resolution we are taking on this matter is: not use those types of urls and instead use simple urls such as .../product/list (to list all products and make searches) and .../product to edit, view or create new products.

          Thanks for the data, will try it latter.
          Great community support!!!

          Comment

          Working...
          X