You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Bobby Mitchell <bo...@niac.usra.edu> on 2002/09/12 16:00:47 UTC

Re: Need help with XMLForm and Mod-db (Please disregard my earlier posts)

My solution is to change the code in DatabaseAction.java to remove the 
table_name. from the variable names. I made this change to test it and 
it works. I suppose I need to change the code in such a way to allow a 
user to supply a configuration directive such as 
<append_table_name>false</append_table_name>. Is there any reason I 
should not do this or is there a better way?

I'm cross-posting this to the dev list.

Bobby Mitchell wrote:

> To start with, I apologize for posting so many different posts lately. 
> I'm stuck and I'm not sure which way to go, but I have been working to 
> find a solution. Please disregard the several earlier posts.
> I'm trying to use XMLForms and Mod-db actions together. My problem 
> stems from the fact that mod-db uses request parameters from a key 
> column to set the ?'s in the query and when setting the request 
> parameters to the column values retrieved it sets them by appending 
> table_name. to the column/req-param name. My request parameters and 
> column names are the same.
>
> Assume my query is select ID, EMAIL from NIAC_MAILLIST where EMAIL=?  
> Mod-db is now looking for a request parameter called 
> NIAC_MAILLIST.EMAIL and if found it successfully grabs the data from 
> the database. Otherwise it exits. If I append 
> &NIAC_MAILLIST.EMAIL="b@n" to the query string mod-db works and 
> creates the variables for the data, but XMLForm generates an "Invalid 
> data format" error. I created a session attribute called 
> NIAC_MAILLIST.EMAIL and am setting it to EMAIL. If mod-db would set  
> the ? from the session attributes instead of request parameters I 
> could set it that way. Otherwise I need to find a way to get mod-db to 
> not append the table name to the front of the column.
> Any ideas?
>
> database.xml
> <root>
>   <connection>niac_db</connection>
>    <table name="NIAC_MAILLIST" alias="NIAC_MAILLIST">
>    <keys>          <key name="EMAIL" type="string" autoincrement="false">
>         </key>
>      </keys>      <values>
>        <value name="ID"  type="int"></value>
>        <value name="EMAIL" type="string"></value>
>      </values>
>   </table>
>   <table-set name="MAILLIST-sel">
>      <table name="NIAC_MAILLIST" others-mode="session"/>
>   </table-set>
> </root>
>
> sitemap snippet where I declare the select action
> <map:action name="mod-db-sel     
> src="org.apache.cocoon.acting.modular.DatabaseSelectAction">
>          <descriptor>database.xml</descriptor>
>          <throw-exception>true</throw-exception>
> </map:action>
>
> pipeline where I'm trying to use it.   
>                                                                                
>
>    <map:pipeline>
>
>      <!-- A non-trivial interactive example - Cocoon Usage Feedback 
> Wizard -->
>      <map:match pattern="wizard*">
>
>        <map:match type="request-parameter" pattern="cocoon-xmlform-view">
>          <map:select type="request-parameter">
>            <map:parameter name="parameter-name" 
> value="cocoon-xmlform-view"/>
>            <map:when test="registration">
> <!--
>              <map:act type="request">
>                <map:parameter name="parameters" value="true"/>
> -->
>              <map:act type="req-params">
>                <map:parameter name="parameters" value="EMAIL"/>
>                <map:act type="session-propagator">
>                  <map:parameter name="NIAC_MAILLIST.EMAIL" 
> value="{EMAIL}"/>
>                </map:act>
>                <map:act type="mod-db-sel" src="optional src">
>                  <map:parameter name="table-set" value="MAILLIST-sel"/>
>                </map:act>
>              </map:act>
>            </map:when>
>          </map:select>
>        </map:match>
>
>        <map:act type="WizardAction">
>
>          <!-- 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="schematron/wizard-xmlform-sch-report.xml"/>
>          <map:parameter name="xmlform-id" value="form-feedback"/>
>          <map:parameter name="xmlform-scope" value="session"/>
>          <map:parameter name="xmlform-model" value="niac.list.ListBean"/>
>
>          <!-- Content transformation logic -->
>          <map:generate type="serverpages" src="wizard/{page}.xsp"/>
>          <map:transform type="xmlform"  label="debug, xml"/>
>          <map:transform src="stylesheets/wizard2html.xsl" />
>          <map:transform 
> src="context://samples/stylesheets/xmlform/xmlform2html.xsl"/>
>          <map:serialize type="xhtml"/>
>        </map:act>
>      </map:match>
>    </map:pipeline>
>
>


-- 
Robert J. (Bobby) Mitchell
Systems Administrator
NASA Institute for Advanced Concepts
555A 14th St Atlanta, Ga. 30318
Phone: (404)347-9633 Fax: (404)347-9638





---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: Need help with XMLForm and Mod-db (Please disregard my earlier posts)

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 12.Sep.2002 -- 10:00 AM, Bobby Mitchell wrote:
> My solution is to change the code in DatabaseAction.java to remove the 
> table_name. from the variable names. I made this change to test it and 
> it works. I suppose I need to change the code in such a way to allow a 
> user to supply a configuration directive such as 
> <append_table_name>false</append_table_name>. Is there any reason I 
> should not do this or is there a better way?
> 
> I'm cross-posting this to the dev list.
> 
> Bobby Mitchell wrote:
> 
> >To start with, I apologize for posting so many different posts lately. 
> >I'm stuck and I'm not sure which way to go, but I have been working to 
> >find a solution. Please disregard the several earlier posts.
> >I'm trying to use XMLForms and Mod-db actions together. My problem 
> >stems from the fact that mod-db uses request parameters from a key 
> >column to set the ?'s in the query and when setting the request 
> >parameters to the column values retrieved it sets them by appending 
> >table_name. to the column/req-param name. My request parameters and 
> >column names are the same.
> >
> >Assume my query is select ID, EMAIL from NIAC_MAILLIST where EMAIL=?  
> >Mod-db is now looking for a request parameter called 
> >NIAC_MAILLIST.EMAIL and if found it successfully grabs the data from 
> >the database. Otherwise it exits. If I append 
> >&NIAC_MAILLIST.EMAIL="b@n" to the query string mod-db works and 
> >creates the variables for the data, but XMLForm generates an "Invalid 
> >data format" error. I created a session attribute called 
> >NIAC_MAILLIST.EMAIL and am setting it to EMAIL. If mod-db would set  
> >the ? from the session attributes instead of request parameters I 
> >could set it that way. Otherwise I need to find a way to get mod-db to 
> >not append the table name to the front of the column.
> >Any ideas?

Bobby, mod-db defaults to using request parameters in order to make a 
transition from the other database actions easy. However, it employs the
<mode/> tags nested into <value/> end <key/> tags to specify the 
InputModule to use. In addition you can give the InputModule instructions
where to look for the data.

Hence, you could obtain some or all data from the session and specify the
name of the session attribute to use as well. You could even interpret
the session attribute as java.util.Map and use a specific entry.

This should be described in the InputModules documentation. Advanced uses
are described in the javadocs for the specific InputModules.

> >database.xml
> ><root>
> >  <connection>niac_db</connection>
> >   <table name="NIAC_MAILLIST" alias="NIAC_MAILLIST">
> >   <keys>          <key name="EMAIL" type="string" autoincrement="false">
> >        </key>
> >     </keys>      <values>
> >       <value name="ID"  type="int"></value>

Here you could say
          <value name="ID" type="int">
             <mode type="all" name="session" parameter="foo"/>
          </value>

You could even pass more configuration info to the InputModule by nesting
it into the <mode/> tag.

> >       <value name="EMAIL" type="string"></value>
> >     </values>
> >  </table>
> >  <table-set name="MAILLIST-sel">
> >     <table name="NIAC_MAILLIST" others-mode="session"/>
> >  </table-set>
> ></root>

Besides you patch to turn off name prefixing looks worthwhile and I will
look more into it when I'm back from travelling next week.

	Chris.
-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org