cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Fagnani-Bell <jus...@paraliansoftware.com>
Subject Re: dynamically choosing an action at runtime
Date Mon, 04 Nov 2002 20:47:25 GMT
Josema,

   You don't have to include the parts of your pipeline that are the 
same in the <map:when> elements. You can just include the <map:act> 
element, since it appears that you're not returning any parameters from 
your action, and then you won't have to duplicate the part that doesn't 
vary.

   An even better way would be to have a proxy Action class that 
dynamically loads a particular helps class depending on a parameter 
passed to it. Cocoon already includes something like this with 
ServerPagesAction, and you write the action in XSP.

Justin


On Monday, November 4, 2002, at 09:57  AM, Josema Alonso wrote:

>> Just use appropriate selector:
>> http://xml.apache.org/cocoon/userdocs/selectors/selectors.html
>>
> I already tried but haven't found a nice way of using them for this 
> purpose.
> I can make something like the pipeline below, but i have dozens of 
> similar
> cases and it doesn't seem like a good approach. Maybe I haven't 
> understood
> selectors well...
>
>
> --------------------------------------
>   <!-- XMLForms pipeline -->
>   <map:pipeline>
>    <map:match pattern="*">
>     <map:select type="parameter">
>      <map:parameter name="parameter-selector-test" value="{1}"/>
>      <!-- Case #1 -->
>      <map:when test="EquipmentType">
>       <map:act type="EquipmentTypeAction">
>        <!-- XMLForm parameters for the AbstractXMLFormAction -->
>        <map:parameter name="xmlform-validator-schema-ns"
> value="http://www.ascc.net/xml/schematron"/>
>        <map:parameter name="xmlform-validator-schema"
> value="{1}/schematron/{1}-validator.xml"/>
>        <map:parameter name="xmlform-id" value="form-insert"/>
>        <map:parameter name="xmlform-scope" value="session"/>
>        <map:parameter name="xmlform-model"
> value="net.josema.xmtrader.forms.xmldb.recordings.equipment.{1}Bean"/>
>        <!-- original XMLForm document -->
>        <map:generate src="{../1}/{page}.xml"/>
>        <!-- populating the document with model instance data -->
>        <map:transform type="xmlform" label="debug, xml"/>
>        <!-- personalizing the look and feel of the form controls  -->
>        <map:transform src="styles/wizard2html.xsl"/>
>        <!-- Transforming the XMLForm controls to HTML controls -->
>        <map:transform src="styles/xmlform2html.xsl"/>
>        <!-- sending the HTML back to the browser -->
>        <map:serialize type="html"/>
>       </map:act>
>      </map:when>
>      <!-- Case #2, very very similar to the first one, it should be a 
> better
> way to choose between both -->
>      <map:when test="RecordingType">
>       <map:act type="RecordingTypeAction">
>        <!-- XMLForm parameters for the AbstractXMLFormAction -->
>        <map:parameter name="xmlform-validator-schema-ns"
> value="http://www.ascc.net/xml/schematron"/>
>        <map:parameter name="xmlform-validator-schema"
> value="{1}/schematron/{1}-validator.xml"/>
>        <map:parameter name="xmlform-id" value="form-insert"/>
>        <map:parameter name="xmlform-scope" value="session"/>
>        <map:parameter name="xmlform-model"
> value="net.josema.xmtrader.forms.xmldb.recordings.equipment.{1}Bean"/>
>        <!-- original XMLForm document -->
>        <map:generate src="{../1}/{page}.xml"/>
>        <!-- populating the document with model instance data -->
>        <map:transform type="xmlform" label="debug, xml"/>
>        <!-- personalizing the look and feel of the form controls  -->
>        <map:transform src="styles/wizard2html.xsl"/>
>        <!-- Transforming the XMLForm controls to HTML controls -->
>        <map:transform src="styles/xmlform2html.xsl"/>
>        <!-- sending the HTML back to the browser -->
>        <map:serialize type="html"/>
>       </map:act>
>      </map:when>
>     </map:select>
>    </map:match>
>   </map:pipeline>
>
>
>
> ---------------------------------------------------------------------
> 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