Tapestry never disappoints! Single page loading content from
activation context is so simple and easy, it just feels like the right
way to go!

Here is what I've got which pretty much works. Static publishable
content wrapped around a layout. Few questions regarding possible
improvements:

* Is there anything fundamentally wrong with what I have (I haven't
coded Tapestry in years)?
* Is there a better way to store file content (cache?). Not sure if
reading it on each access is the right way to go.
* I supposed I need to look for the right file name myself based on
the locale? page1.html page1_fr.html etc etc. We do that currently, so
no problem if not, but checking if there is any helpful utility
resolver out there?

my.app.tapestry.components
public class Cms {

        @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
        private String target;
        
        @Inject
        private Locale locale;
        
        @Inject
        private Logger log;
        
        @BeginRender
        void renderMessage(MarkupWriter writer) {
                
                log.debug(locale.toString());
                
                File f = new File("cms/" + target + ".html");
                try {
                        String s = FileUtils.readFileToString(f);
                        writer.writeRaw(s);
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        writer.writeRaw("<b>ERROR</b> reading file");
                }
        }
}

my.app.tapestry.pages
public class Info {

        @SuppressWarnings("unused")
        @Property(write=false)
        private String target;
        
        
        void onActivate(String aParam) {
                target = aParam;
        }
}

Info.tml
<t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
<t:cms t:target="${target}"/>
</t:layout>

projectRoot/cms/
 - page1.html

Requesting 127.0.0.1/info/page1.html   works like a charm :)

Adam


On Fri, Jul 23, 2010 at 12:51 PM, Michael Gentry <mgen...@masslight.net> wrote:
> On Fri, Jul 23, 2010 at 12:51 PM, Thiago H. de Paula Figueiredo
> <thiag...@gmail.com> wrote:
>> Struts is a completely different beast when compared to Tapestry, so most of
>> the approaches used in one don't apply to the other.
>
> I think that's why we are here, Thiago.  :-)
>
> mrg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

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

Reply via email to