You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Daniel Stefaniuk <da...@gmail.com> on 2011/04/11 16:30:56 UTC
prepare attribute
Hi
I would like to use object (UIBootstrap.Dojo) created in the layout inside
of a view (content). This is an example:
<html>
<head>
<%
UIBootstrap.Dojo dojo = new UIBootstrap.Dojo();
// save Dojo Toolkit bootstrap object to allow further configration in a
view
request.setAttribute("dojo", dojo);
%>
<!-- this is the place I want to execute content but output it later on -->
<%= new UIBootstrap().setDojo(dojo) %>
</head>
<body>
<tiles:insertAttribute name="content" />
</body>
</html>
The problem with that solution is that the UIBootstrap.Dojo object is
outputted before content is rendered. Any amendments made to
UIBootstrap.Dojo object inside of a view are done too late.
Is there any way to execute content but output it later on?
Thanks
Daniel
Re: prepare attribute
Posted by Antonio Petrelli <an...@gmail.com>.
2011/4/11 Daniel Stefaniuk <da...@gmail.com>
> I should simplify the example:
>
> *TitleHelper.java*
>
> public interface TitleHelper {
> void setTitle(String title);
> String getTitle();
> }
>
> *content.jsp*
>
> <%
> TitleHelper th = (TitleHelper) request.getAttribute("th");
> th.setTitle("My View");
> %>
> <div>
> This is a content of a view.
> </div>
>
> *layout.jsp*
>
> <html>
> <head>
> <%
> TitleHelper th = new TitleHelperImpl();
> // in the real world complicated state of TitleHelper is assigned here
>
> request.setAttribute("th", th);
> %>
> <title><%= th.toString %></title>
>
> </head>
> <body>
> <tiles:insertAttribute name="content" />
> </body>
> </html>
>
> I hope now it is clear what I meant.
>
So you want that a JSP file changes code of an already outputted variable
and you expect it changes? I bet it does not work! :-D
What you want to do is impossible, independently to Tiles, JSP or whatever
template engine you use: if it is written to output it cannot ever change
(at least server-side).
Try to explain what is your use case in plain words so we can try to sort it
out.
Antonio
Re: prepare attribute
Posted by Daniel Stefaniuk <da...@gmail.com>.
I should simplify the example:
*TitleHelper.java*
public interface TitleHelper {
void setTitle(String title);
String getTitle();
}
*content.jsp*
<%
TitleHelper th = (TitleHelper) request.getAttribute("th");
th.setTitle("My View");
%>
<div>
This is a content of a view.
</div>
*layout.jsp*
<html>
<head>
<%
TitleHelper th = new TitleHelperImpl();
// in the real world complicated state of TitleHelper is assigned here
request.setAttribute("th", th);
%>
<title><%= th.toString %></title>
</head>
<body>
<tiles:insertAttribute name="content" />
</body>
</html>
I hope now it is clear what I meant.
Daniel
On 11 April 2011 15:54, Antonio Petrelli <an...@gmail.com> wrote:
> 2011/4/11 Daniel Stefaniuk <da...@gmail.com>
>
> > It has nothing to do with JavaScript and it maybe related more to the JSP
> > rendering engine than to Tiles itself.
> >
>
> Dojo? Are you sure?
>
>
> > However, I wonder if there is a way to execute content, that is a JSP
> file
> > defined as "content" attribute, grab that content for example as a string
> > and then output it in the HTML body. Please, bear in mind that we are
> still
> > on the server side, not in a browser.
> >
>
> What do you mean with "execute" content? Is it Javascript?
>
> Antonio
>
Re: prepare attribute
Posted by Antonio Petrelli <an...@gmail.com>.
2011/4/11 Daniel Stefaniuk <da...@gmail.com>
> It has nothing to do with JavaScript and it maybe related more to the JSP
> rendering engine than to Tiles itself.
>
Dojo? Are you sure?
> However, I wonder if there is a way to execute content, that is a JSP file
> defined as "content" attribute, grab that content for example as a string
> and then output it in the HTML body. Please, bear in mind that we are still
> on the server side, not in a browser.
>
What do you mean with "execute" content? Is it Javascript?
Antonio
Re: prepare attribute
Posted by Daniel Stefaniuk <da...@gmail.com>.
It has nothing to do with JavaScript and it maybe related more to the JSP
rendering engine than to Tiles itself.
However, I wonder if there is a way to execute content, that is a JSP file
defined as "content" attribute, grab that content for example as a string
and then output it in the HTML body. Please, bear in mind that we are still
on the server side, not in a browser.
Re: prepare attribute
Posted by Antonio Petrelli <an...@gmail.com>.
2011/4/11 Daniel Stefaniuk <da...@gmail.com>
> Hi
>
> I would like to use object (UIBootstrap.Dojo) created in the layout inside
> of a view (content). This is an example:
>
> <html>
> <head>
> <%
> UIBootstrap.Dojo dojo = new UIBootstrap.Dojo();
> // save Dojo Toolkit bootstrap object to allow further configration in a
> view
> request.setAttribute("dojo", dojo);
> %>
> <!-- this is the place I want to execute content but output it later on -->
> <%= new UIBootstrap().setDojo(dojo) %>
> </head>
> <body>
> <tiles:insertAttribute name="content" />
> </body>
> </html>
>
> The problem with that solution is that the UIBootstrap.Dojo object is
> outputted before content is rendered. Any amendments made to
> UIBootstrap.Dojo object inside of a view are done too late.
>
> Is there any way to execute content but output it later on?
>
I don't think it is related to Tiles, however...
I think you might want to bind an init function to window.onload.
Antonio