You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Lee Theobald <Le...@openobjects.com> on 2008/01/24 14:35:47 UTC

Where To Define My Constants?

A nice simple one this time.

Currently in my non-tiles web application I have a page called config.jsp
that sets a number of variables on the page context (via
pageContext.setAttribute).  This page is then included at the top of each of
my top level pages (which is just a few HTML tags and then a lot of
includes).  So I know that my includes will be able to access this variable.

Now I'm trying to do the same while using tiles.  But where should I include
my config.jsp so that the variables defined within it are available through
the various pages inserted into my template?  I've tried putting it in the
template file but this only works for that single page.  I also just gave it
a shot at inserting into my top level page (that uses a template and
provides the various parts to be inserted) but the variables still aren't
available in the various includes.

If that didn't make much sense, let me know and I'll try and illustrate it
visually.

Cheers,
Lee
-- 
View this message in context: http://www.nabble.com/Where-To-Define-My-Constants--tp15063959p15063959.html
Sent from the tiles users mailing list archive at Nabble.com.


Re: Where To Define My Constants?

Posted by Antonio Petrelli <an...@gmail.com>.
2008/1/25, Lee Theobald <Le...@openobjects.com>:
>
> In addition to those, I have three JSP files containing various variables:
> *  general_config - Which contains various strings, booleans, arrays etc.
> to
> be used on either page (search or results).
> *  search_config - Same kind of deal but just to be used for the search
> page
> *  results_config - Same as above but for results.
>
> All the variables are defined currently on the pageContext.
>
> What's the best way to make the variables available in the config pages
> available to the search & results pages?



I don't know if it is the "best" way, but you can define them at request
scope.

Antonio

Re: Where To Define My Constants?

Posted by Lee Theobald <Le...@openobjects.com>.
Possibly, I'm not too sure.  Let me put the question in a better way...

I have two pages: search.jsp and results.jsp.  One is a search page, the
other a results page.
Those pages also have their own templates: search_template.jsp and
result_template.jsp.

In addition to those, I have three JSP files containing various variables:
*  general_config - Which contains various strings, booleans, arrays etc. to
be used on either page (search or results).
*  search_config - Same kind of deal but just to be used for the search page
*  results_config - Same as above but for results.

All the variables are defined currently on the pageContext.

What's the best way to make the variables available in the config pages
available to the search & results pages?

So far I've tried things like:
<code>
<tiles:insertTemplate template="templates/search_template.jsp">
	<tiles:putAttribute name="generalconfig" type="template"
value="../includes/general_config.jsp" />
        <tiles:putAttribute name="specifcconfig" type="template"
value="../includes/search_config.jsp" />
        ...
</tiles:insertTemplate>
But that hasn't seemed to work.  Just including the config files in
search_template doesn't work either.

Do I have to set up my template so that all the variables I want are defined
via <tiles:putAttribute>.  I'm starting to think this is where I should be
starting to use definitions (which I have been avoiding so far).

Cheers for any input,
Lee
-- 
View this message in context: http://www.nabble.com/-Tiles2--Where-To-Define-My-Constants--tp15063959p15083808.html
Sent from the tiles users mailing list archive at Nabble.com.


Re: Where To Define My Constants?

Posted by Antonio Petrelli <an...@gmail.com>.
2008/1/24, Lee Theobald <Le...@openobjects.com>:
>
> But where should I include
> my config.jsp so that the variables defined within it are available
> through
> the various pages inserted into my template?



What do you exactly mean by "variables"? Tiles attributes?

Antonio