You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "tapestry.kung.fu" <ba...@gmail.com> on 2012/10/23 05:00:12 UTC

Populating layout parameters and html content from db

I came across this unique need and I am not sure if any of you know how to do
that. 

I have common layout for my site. It has pageTitle which is used to render
title of page, description and keywords field which is used to render "meta
description"  and "met keywords" field respectively.  

Example Index page which is using layout wrapper:

<html t:type="layout" 
      t:pageTitle="Title of this page"
      t:description="Description of this page"
      t:keywords="Keywords for this page"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
      xmlns:p="tapestry:parameter">
     
      HTML content of this page      

</html>

What I want to do is actually render this page via information retrieved
from db. ( I want to store Title, Description and Keywords as text field in
db and HTML content of this page as BLOB in db ).  I am not sure if
parameter values passed in layout component as well as HTML content can be
driven from db. Some pointer would be helpful. 

Thanks in advance.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Populating-layout-parameters-and-html-content-from-db-tp5717154.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Populating layout parameters and html content from db

Posted by "tapestry.kung.fu" <ba...@gmail.com>.
Ok, Never mind... I have jumped to gun too early... Found a Solutions. 

---------------------------------------------------------------------------------------------------------

import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.RequestParameter;

public class TestPage {
	
	@SuppressWarnings("unused")
    @Property
    private String pageTitle;
	
	@SuppressWarnings("unused")
    @Property
    private String description;
	
	@SuppressWarnings("unused")
    @Property
    private String keywords;
	
	@SuppressWarnings("unused")
    @Property
    private String htmlContent;
	  
	void onActivate(@RequestParameter("articleId") long articleId)
	{
	    // Assume DB lookup is done for articleId to pull out pageTitle,
description, keywords and htmlContent from db using some DAO class
		
		this.pageTitle = "pagetitle from db for articleId" + articleId;
		this.description = "description from db for articleId" +  articleId;
		this.keywords ="keywords from db for articleId" +  articleId;
		this.htmlContent = "*
Some html here
*";
	}

}

-----------------------------------------------------------------------------------------------------

<html t:type="layout" 
      t:pageTitle="${pageTitle}"
      t:description="${description}"
      t:keywords="${keywords}"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
      xmlns:p="tapestry:parameter">
      <t:outputraw value="htmlContent" />
</html>


-----------------------------------------------------------------------------------------------------

http://localhost:8080/MyTestApp/TestPage?articleId=1








--
View this message in context: http://tapestry.1045711.n5.nabble.com/Populating-layout-parameters-and-html-content-from-db-tp5717154p5717156.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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