cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From olivier demah <ode...@messagio.com>
Subject XSP: cinclude and map:parameters problem
Date Wed, 21 Apr 2004 13:57:34 GMT
hi,

i try to pass a <map:parameter...> from a <map:pipeline> to a 
<map:cinclude as follow :

example of match : do-home-news.html

[pipeline]
    <map:match pattern="do-*-*.html">

        <map:generate src="xsp/{1}.xsp" type="serverpages">
            <map:parameter name="action" value="{2}"/>
        </map:generate>

        <map:transform type="cinclude"/>
        <map:transform src="xsl/site.xslt"/>
        <map:serialize type="html"/>
    </map:match>
[/pipeline]

then cocoon calls home.xsp page :

[home.xsp]
<?xml version="1.0" encoding="iso-8859-1"?>
<xsp:page   xmlns:xsp= "http://apache.org/xsp"
            xmlns:xsp-request= "http://apache.org/xsp/request/2.0"
            xmlns:esql="http://apache.org/cocoon/SQL/v2"
            xmlns:cinclude="http://apache.org/cocoon/include/1.0">
<root>
<cinclude:include src="cocoon:/site_index.xml" />
<home>
<cinclude:include src="cocoon:/player.xml" />
<cinclude:include src="cocoon:/news.xml" />
</home>
</root>
</xsp:page>
[/home.xsp]

now in my news.xsp script i try to use the "action" parameter with the 
value "news" to build my SQL query
[news.xsp]
<?xml version="1.0" encoding="iso-8859-1"?>
<xsp:page   xmlns:xsp= "http://apache.org/xsp"
            xmlns:xsp-request= "http://apache.org/xsp/request/2.0"
            xmlns:esql="http://apache.org/cocoon/SQL/v2"
            xmlns:cinclude="http://apache.org/cocoon/include/1.0">
<xsp:logic>

private String dateToString_Fr(String ma_date)
{
    if (ma_date.length() &lt; 9) return "";

    String d = ma_date.substring(8, 10);
    String m = ma_date.substring(5, 7);
    String y = ma_date.substring(0, 4);
    String date_fr = d;

    date_fr = date_fr.concat("-");
    date_fr = date_fr.concat(m);
    date_fr = date_fr.concat("-");
    date_fr = date_fr.concat(y);

    return date_fr;
}
</xsp:logic>
<the_news>
<xsp:logic>

String news_category  = parameters.getParameter("action","");

String sql     = "";

sql = "SELECT * FROM m_news WHERE news_category = '"+news_category+"' 
AND news_display = 'oui' ORDER BY  news_date DESC";
    <esql:connection>
        <esql:pool>vieira</esql:pool>
        <esql:execute-query>
            <esql:query><xsp:expr>sql</xsp:expr></esql:query>
            <esql:results>
                <esql:row-results>
                <news>
                    <id_news><esql:get-int column="id_news"/></id_news>
                    <news_category><esql:get-string 
column="news_category"/></news_category>
                    <news_title><esql:get-string 
column="news_title"/></news_title>
                    <news_text><esql:get-string 
column="news_text"/></news_text>
                    <news_teaser><esql:get-string 
column="news_teaser"/></news_teaser>
                    <news_photo><esql:get-string 
column="news_photo"/></news_photo>
                    
<news_date><xsp:expr>dateToString_Fr(<esql:get-string 
column="news_date"/>)</xsp:expr></news_date>
                    <news_display><esql:get-string 
column="news_display"/></news_display>
                </news>
                </esql:row-results>
            </esql:results>
        </esql:execute-query>
    </esql:connection>

</xsp:logic>
</the_news>
</xsp:page>
[/news.xsp]

unfortunnatly the action parameter is _empty_ :-/

i also tried to give a constaint (news e.g) instead of {2} but action is 
definitivly empty.

So i thought ; i had to do something to pass parameters from xsp to xsp 
because i "call" news.xsp with cinclude.


Regards.



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


Mime
View raw message