Jump to content

Action Tag


joecool2005

Recommended Posts

Ok im not sure but this may be what you are talking about. The common approach consists of two steps or of creating two resources. The first resource defines the form: All input fields are declared, each gets a unique name. This form invokes the second resource.This resource uses the session transformer to get the values provided by the user. The values are added by the browser to the parameters of the request. So using the request context and getxml, the values can be fetched.If you want to create a form with two values - forename and surname of the user, you could generate a base xml file with the information about this form:

<page>  <form>    <action>form-handling-page</action>    <input name="forename" type="text"/>    <input name="surname" type="text"/>  </form></page>

A stylesheet can transform this into valid html. The action tag indicates that the "form-handling-page" should be invoked by submitting the values.The "form-handling-page" is a pipeline which is declared in the sitemap and uses the session transformer. It could also read the following xml:

<page xmlns:session="http://apache.org/cocoon/session/1.0">  <forename>    <session:getxml context="request" path="/parameter/forename"/>  </forename>  <surname>    <session:getxml context="request" path="/parameter/surname"/>  </surname></page>

As the form values are appended to the request, getxml with specifying the path (which is the parameter name used for the input field) inserts the value submitted by the user into the xml stream.If you want to write the information in a session context, you must wrap the whole xml inside a setxml:

<page xmlns:session="http://apache.org/cocoon/session/1.0">  <session:setxml context="userdata" path="/user">    <forename>      <session:getxml context="request" path="/parameter/forename"/>    </forename>    <surname>      <session:getxml context="request" path="/parameter/surname"/>    </surname>  </session:setxml></page>

The user data is now stored inside the session context "userdata", so the context has the following content:

<user>  <forename>Walter</forename>  <surname>Walterson</surname></user>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...