Sounds like the mail did not went through...

Jérôme.

----- Message transféré de Jérôme BERNARD <[EMAIL PROTECTED]> -----
   Date : Thu,  2 Oct 2003 13:32:48 +0200
     De : Jérôme BERNARD <[EMAIL PROTECTED]>
Adresse de retour :Jérôme BERNARD <[EMAIL PROTECTED]>
  Sujet : RE: [OS-webwork] Advanced URL mapping?
      À : [EMAIL PROTECTED]

I have been thinking more about what such a mapping confiuration might look like.

Here is a proposal...

I think the easiest thing (in a user perspective) is to define the mapping in
the xwork.xml file.

Suppose we have a LoadArticlePage action. Suppose your model is built with
Article and Page objects where an Article object is made of many Page objects.
Suppose our action loads and expose the content of the specified page of the
specified article. You have getters/setters for the pageID and the articleID and
a getter for the content.

[...]

<action name="LoadArticlePage" class="my.package.LoadArticlesAction">
  <result name="success" type="dispatcher">
    <param name="location">/articles.jsp</param>
  </result>
</action>

[...]

<!--
   we want to be able to handle URL like '/articles/123/4'
   where '123' is the articleID and '4' is the pageID.
-->
<url-mapping>
  <!-- defines the action to use -->
  <action-ref name="LoadArticlePage" namespace="/mynamespace" />
  <!-- binds '/articles/*' to action referenced above -->
  <action-mapping location="/articles/*" />
  <!-- defines how to deal with the rest of the URL -->
  <parameters-mapping>
    <!-- we expect the first parameter to be the article id -->
    <parameter-mapping name="articleID" />
    <!-- we expect the second parameter to be the page id -->
    <parameter-mapping name="pageID" />
  </parameters-mapping>
</url-mapping>


What happens now if we want to display the whole article (which means displaying
all pages of the specified article)? Well we would simply write the execute()
method in such a way that if the pageID is not specified then we are supposed to
load all pages and return the content of all pages concatenated.


What is left though is how to deal with dates?
Perhaps we could alter the 'parameter-mapping' tag so that it accepts optional
parameters like 'kind' and 'format'. Then handling dates could be done like this:

[...]
<parameter-mapping name="dateOfPublication" kind="date" format="YYYYMMDD" />
[...]

That way suppose we want to handle the following kind of URLs:
- http://myhost.com/articles/2003/10/01
- http://myhost.com/articles/2003/10
- http://myhost.com/articles/2003

We would define 3 mappings using a parameter with a kind set to "date" and 3
different formats (respectively 'YYYYMMDD', 'YYYYMM' and 'YYYY').

I might have forgotten some other issues.

What do you think about such a proposal?

Regards,
Jérôme.
----- Fin du message transféré -----




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to