cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robby Pelssers" <robby.pelss...@ciber.com>
Subject RE: How to I can do to capture the html code
Date Fri, 05 Nov 2010 08:04:01 GMT
A vague question if you ask me...

What version of cocoon are you using by the way?  2.2?


Let's assume you have one of 2 options below configured in your sitemap:

<!-- option 1: using request parameters -->
<map:match pattern="mypage.html">
  <map:call function="generateMyPage"/>
</map:match>

<!-- option 2: using sitemap parameters -->
<map:match pattern="mypage/*">
  <map:call function="generateMyPage">
    <map:parameter name="id" value="{1}"/>
  </map:call>
</map:match>

You would invoke option 1 like:

http://localhost:8080/mywebapp/myblock/mypage.html?id=1040

option 2 can be invoked like:

http://localhost:8080/mywebapp/myblock/mypage/1040


Now your flowscript controller 

option 1:

function generateMyPage() {
    var id = cocoon.request.getParameter("id");
    //fetch additional data
    var employees = cocooon.getComponent("dataSource").findById(id);
    cocoon.sendPage(
        "mypage2html",
        { 
          "id": id, "employees ": employees
        }
    );
}

option 2:

function generateMyPage() {
   var id = cocoon.parameters["id"];
    //fetch additional data
    var employees = cocooon.getComponent("dataSource").findById(id);
    cocoon.sendPage(
        "mypage2html",
        { 
          "id": id, "employees ": employees
        }
    );
}

So you will also need a jxtemplate to render you html:

<map:match pattern="mypage2html">
  <map:generate src="pages/mypage.jx" type="jx"/>
  <map:serialize type="xhtml"/>
</map:match>


the template could look like:

<?xml version="1.0" encoding="UTF-8"?>
<jx:template 
  xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
  <html>
    <head>
      <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />     
      <title>Some Title </title>
      <link type="text/css" rel="stylesheet" href="resource/external/css/styles.css"/>
	    			       	    
    </head>
    <body>
      <span>You invoked page with id ${id}</span>
      <table>
        <thead>
          <tr> 
            <th>First Name</th>
            <th>Last Name</th>
          </tr>
        </thead>
        <tbody>
          <jx:forEach var="employee" items="${employees}">
            <tr>
              <td>${employee.fName}</td>
              <td>${employee.lName}</td>
            </tr>
          </jx:forEach>         
        </tbody>
      </table>
    </body>    
  </html>
</jx:template>

So the result of invoking both URL's is an xhtml page.

Robby
-----Oorspronkelijk bericht-----
Van: tgarijo [mailto:tgarijo@clickonline.es]
Verzonden: do 4-11-2010 17:57
Aan: users@cocoon.apache.org
Onderwerp: How to  I can do to capture the html code
 

Hi all

I am developing an application where a remote url call my url defined in my
sitemap. I will return it to the url a number of data and the url returns me
a html code. I develop with myeclipse and html code that it returned , is
printed in the console of my eclipse. How to  I can do to capture the html
code that url send me and set up a web page?

Thank you

Sorry for my English.

-- 
View this message in context: http://old.nabble.com/How-to--I-can-do-to-capture-the-html-code-tp30134015p30134015.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


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



Mime
View raw message