You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jo...@fimat.com on 2005/09/05 13:55:07 UTC
CForms Selection-list: cannot replace user-selected item
Hi there,
I have a problem with CForms selection lists. What I am trying to do is
the following:
The user selects a report name in a selection-list where the names are
shown in human-readable form (e.g. "Money Statement"). I want to trigger a
pdf processing pipeline, but my stylesheets have short names, e.g. the one
for "Money Statement" is called "MT950MS.xsl". So this is what I want to
include in my call to sendPage.
The problem is: This translation doesn't work, what is passed back by
sendPage is always the string the user selected. In my flow script (see
below) I translate the long name using a function
"chooseMessageType":
var mt = chooseMessageType(model.reportType);
Then I define the hash used in my call to sendPage:
var bizdata = { "reportType" : mt, "account" : model.account,
"reportDate" : model.reportDate }
Finally, the call to sendPage:
cocoon.sendPage("create", bizdata);
What have I done wrong?
I am using Cocoon-2.1.7 with Jetty on Windows 2000.
The relevant portions of my Cocoon application are as follows:
----------------------------------
Form Definition:
....
<fd:widgets>
<fd:field id="reportType" required="true">
<fd:label>Report type:</fd:label>
<fd:datatype base="string"/>
<fd:selection-list id="reportType" required="true">
<fd:item value="Monthly Interest Scales"/>
<fd:item value="Money Statement"/>
...
</fd:selection-list>
</fd:field>
....
-----------------------------------
Flow:
cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
function chooseMessageType (longName) {
var ret="";
switch (longName) {
case "Monthly Interest Scales":
ret="MT935";
break;
case "Money Statement":
ret="MT950MS";
break;
....
}
return ret;
}
function reportSelection() {
var url = "forms/selectReport.xml";
var form = new Form(url);
form.showForm("reportSelection");
var model = form.getModel();
var mt = chooseMessageType(model.reportType);
var bizdata = { "reportType" : mt, "account" : model.account,
"reportDate" : model.reportDate }
cocoon.sendPage("create", bizdata);
}
-----------------------------------
Sitemap:
<map:match pattern="create">
<map:generate
src="context://CreationOnlineViaCocoon/xml/{request-param:reportType}XML_{request-param:account}_{request-param:reportDate}.xml"/>
<map:transform
src="context://CreationOnlineViaCocoon/xsl/{request-param:reportType}.xsl"/>
<map:serialize type="fo2pdf"/>
</map:match>
Kind Regards
José Diaz Seng
Re: CForms Selection-list: cannot replace user-selected item
Posted by Jason Johnston <co...@lojjic.net>.
Jose.Diaz.Seng@fimat.com wrote:
>
> I don't know why Lotus Notes mixes up my emails this way. So here's one
> more try:
>
> Sitemap:
>
> ....
> <map:match pattern="create">
> <map:generate src="context:.../{request-param:reportType}
> XML_{request-param:account}_{request-param:reportDate}.xml"/>
> <map:transform src="context:...{request-param:reportType}.xsl"/>
> <map:serialize type="fo2pdf"/>
> </map:match>
> ....
I think you don't want to be using the request-param: input module here,
but instead use the flow-attr: module which allows access to the
viewdata provided by the flowscript in the second argument to sendPage.
The request parameters are not affected by flow, so it makes sense
that it's getting the value originally submitted by the HTML form.
Another option might be to actually use the "short" values as the option
values in your selection list, and the "long" value as the label, for
example:
<fd:selection-list>
<fd:item value="MT935"><fd:label>Monthly Interest
Scales</fd:label></fd:item>
<fd:item value="MT950MS"><fd:label>Money Statement</fd:label></fd:item>
</fd:selection-list>
That way the short value is the one that gets submitted to the server so
you don't have to translate it later in your flow, and the user still
sees the long value. It would also allow you to translate the label in
the future.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: CForms Selection-list: cannot replace user-selected item
Posted by Jo...@fimat.com.
I don't know why Lotus Notes mixes up my emails this way. So here's one
more try:
Sitemap:
....
<map:match pattern="create">
<map:generate src="context:.../{request-param:reportType}
XML_{request-param:account}_{request-param:reportDate}.xml"/>
<map:transform src="context:...{request-param:reportType}.xsl"/>
<map:serialize type="fo2pdf"/>
</map:match>
....
Re: CForms Selection-list: cannot replace user-selected item
Posted by Jo...@fimat.com.
sorry, my mail program chopped off part of the sitemap definition. The
relevant part should read as follows:
<map:match pattern="create">
<map:generate src="context://.../xml/{request-param:reportType}
XML_{request-param:account}_{request-param:reportDate}.xml"/>
<map:transform
src="context://.../xsl/{request-param:reportType}.xsl"/>
<map:serialize type="fo2pdf"/>
</map:match>