cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Piroumian Konstantin <KPiroum...@protek.com>
Subject RE: Elegant solution for filling forms
Date Mon, 24 Jun 2002 12:27:41 GMT
> From: Andrei Svirida [mailto:andrei.svirida@midray.com] 
> 
> Hello Cocooners,
> 
> I have a simple problem filling the values of my form fields.
> As it seems to be rather common and oft occuring problem i 
> hope somebody knows a solution.

Take a look at the XMLForm. It solves this kind of problems, such as mapping
your data to your form fields, mapping request parameters to your data
model, rules-based validation. See below for more:

> 
> I have a form described in XML file test.xml (used with Stylebook
> Stylesheets) :
> 
> ---
>  <form name="testform">
>       Text:<text name="city" size="20"/>
>  </form>
> ---
> 
> I also have an Cocoon Action "GetCityAction" which sets the parameter
> "city" in the sitemap.
> 
> I want the user to see the current value of the field "city" 
> in browser, so
> the content of test.xml must be changed to
> ---
>  <form name="testform">
>       Text:<text name="city" size="20" value="cologne"/>
>  </form>
> ---
> before passing it to Stylebook stylessheets transformer.
> 
> Is there some elegant way to do it?

If for some reason you don't want to use XMLForm then you can simply write a
transformer that performs this. 

> 
> I know that could be achieved by writing a stylesheets like
> ----
> <xsl:param name="city"/>
> <xsl:template match="text">
>  <xsl:if test="@name='city'">
>     <text name="city" size="@size" value="$city" />
>  </xsl:if>
>  ....
> </xsl:template>
> ----
> and sitemap like:
> <map:act type="GetCityAction">
>   <map:generate src="test.xml">
>   <map:transform src="stylesheets/apache.xsl">
>     <map:parameter name="city" value="{city}" />
>   </map:transform>
>   ...
> </map:act>
> ---------
> 
> but i don't want to change my stylesheets every time i add a new
> variable to the form.

And you would also add another action too. I'd use one action to get the
data and then will use either request attributes or session to pass the data
to a transformer which would fill in your form. It really worth to take a
look at the XMLForm.

Konstantin

>   
> 
> --
> Andrei Svirida, Projekte & Entwicklung
> MIDRAY GmbH - a debitel company
> Phone:  +49.221.8884 435 
> Fax:    +49.221.8884 455
> 
http://www.midray.com/


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message