You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by st...@gmail.com on 2007/05/01 16:37:17 UTC

Re: Tiles 2 woes

Antonio --

Does the ViewPreparer (aka Tiles Controller) has access to the OGNL stack?
I am trying to figure out a way to push beans on the root of the tree (like
S2 does) so the S2 custom tags will implicitly link up with them from my
page parts.  The only thing I have been able to figure out so far is how to
attach the tiles controller generated beans to the #request object which
results in messy jsp code.



Scott


On 4/12/07, Antonio Petrelli <an...@gmail.com> wrote:
>
> 2007/4/12, stanlick@gmail.com <st...@gmail.com>:
> > Thanks Antonio.  This is what I decided after searching through the
> Tiles
> > jar for "prepare".  Can you tell me if Tiles2 is documented somewhere.
>
> Documentation is on the way, since we were busy preparing a release
> (and having Easter holidays :-) ) it never came out, but I hope it is
> a question of some weeks.
> The official Tiles site is:
> http://tiles.apache.org/
>
>
> > Also, is there a guide that explains the required changes when migrating
> > Tiles1 to Tiles2?
>
> I am working on it right now.
>
> >  This looks like some really nice work and I'm happy to
> > see that Tiles has remained in lockstep with Struts.  I have used Tiles
> for
> > years and have always thought it was one of the greatest strengths of
> > Struts.  In fact, most developers around here don't even view them as
> being
> > unrelated.  This is probably why I posted in the Struts area.
>
> I assume that you are not alone, there are still some Struts pages
> that refer to Tiles 2 as a "sandbox project", and Struts-Tiles is
> still there, though it seems not to be supported anymore.
>
> >
> > Sorry about that,
>
> Don't be sorry, you were in the *right* mailing list in your first
> questions, but then they became Tiles-related and not Struts-related.
>
> Anyway stay tuned for a release of Tiles 2 very soon.
>
> Antonio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Scott
stanlick@gmail.com

Re: Tiles 2 woes

Posted by Dave Newton <ne...@yahoo.com>.
--- stanlick@gmail.com wrote:
> stack = (ValueStack)
> tilesContext.getRequestScope().get(
> ServletActionContext.STRUTS_VALUESTACK_KEY);
> 
> works from within the Tiles controller!

Yeah, that's why I posted it :/

> It appears to be in the zero element, but I'd
> like to be certain of this.  

AFAIK this guaranteed; that's how all the S2 tags work
without having to explicitly state which stack value
you're referencing.

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles 2 woes

Posted by st...@gmail.com.
stack = (ValueStack) tilesContext.getRequestScope().get(
ServletActionContext.STRUTS_VALUESTACK_KEY);

works from within the Tiles controller!  Now then, stack.getRoot() returns a
CompoundRoot which appears to be a Collection.  Is there a way to know which
element the Action is in?  It appears to be in the zero element, but I'd
like to be certain of this.  Too bad it isn't keyed!

On 5/2/07, Dave Newton <ne...@yahoo.com> wrote:
>
> --- stanlick@gmail.com wrote:
> > In short... workflow.
>
> Oh. I just know about the Tiles/OGNL stuff :)
>
> d.
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Scott
stanlick@gmail.com

Re: Tiles 2 woes

Posted by Dave Newton <ne...@yahoo.com>.
--- stanlick@gmail.com wrote:
> In short... workflow. 

Oh. I just know about the Tiles/OGNL stuff :)

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles 2 woes

Posted by st...@gmail.com.
In short... workflow. I am trying to leverage XML validation, wildcards,
tiles, and a Spring injected Action.  Also, I'm trying to wire the results
in the action mapping in such a way that I am not recreating the wheel each
time I need another CRUD.  It just seems like some of the parts within this
equation are working against other parts.  I could easily code this using
verbose configuration if I were not concerned with duplicating effort for
the next CRUD.

On 5/2/07, Dave Newton <ne...@yahoo.com> wrote:
>
> --- stanlick@gmail.com wrote:
> > Actions work with beans/OGNL in a custom tag
> friendly
> > way; tiles does not.  The ViewPreparer works fine
> for
> > stashing collections of beans in the request
> > scope and then manually working them into the JSP.
>
> I don't think the list supports attachments; at least
> I didn't get anything.
>
> What I'm saying, though, is that you can put anything
> you want onto the OGNL stack from within a Tiles view
> preparer (for my test I extended whatever that base
> class w/ the execute(...) method) and access them
> through the S2 tags.
>
> I tested both placing named objects on the stack via
> set(ognlExpression, object) and push(object).
>
> What specifically isn't working for you?
>
> d.
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Scott
stanlick@gmail.com

Re: Tiles 2 woes

Posted by Dave Newton <ne...@yahoo.com>.
--- stanlick@gmail.com wrote:
> Actions work with beans/OGNL in a custom tag
friendly
> way; tiles does not.  The ViewPreparer works fine
for
> stashing collections of beans in the request
> scope and then manually working them into the JSP. 

I don't think the list supports attachments; at least
I didn't get anything.

What I'm saying, though, is that you can put anything
you want onto the OGNL stack from within a Tiles view
preparer (for my test I extended whatever that base
class w/ the execute(...) method) and access them
through the S2 tags. 

I tested both placing named objects on the stack via
set(ognlExpression, object) and push(object).

What specifically isn't working for you?

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles 2 woes

Posted by st...@gmail.com.
Thanks Dave --

Perhaps if I explain this in a different context we can arrive at the
optimum solution.  To begin, I am writing a generic CRUD where all my
results are complex "tiles" pages.  I have a single Action that handles each
of the CRUD user gestures as follows:

        <action name="course_*" method="{1}" class="course">
            <result name="input"      type="tiles">{1}Course.page</result>
            <result name="list"         type="tiles">{1}Course.page</result>
            <result name="add"        type="tiles">{1}Course.page</result>
            <result name="show"      type="tiles">{1}Course.page</result>
            <result name="edit"
type="tiles">{1}Course.page</result>
            <result name="destroy"   type="tiles">{1}Course.page</result>

        </action>

After trying several techniques to prepare the tiles using S2 and falling
short, I then shifted my concentration to the Tiles ViewPreparer to perform
the tiles setup.  From that vantage point, is was even worse!  Actions work
with beans/OGNL in a custom tag friendly way; tiles does not.  The
ViewPreparer works fine for stashing collections of beans in the request
scope and then manually working them into the JSP.  What I nearly have
working is the attached workflow.

Examples to better understand graphic

hyperlink=course_add
method=add() in CourseAction
result=add from add() in CourseAction
tile=addCourse.page
tile <form> action=course_save() in CourseAction

Re: Tiles 2 woes

Posted by Dave Newton <ne...@yahoo.com>.
For the sake of completeness, this appears to work
fine.

I can access values using the S2 tags from ValueStack
from the tile's JSP, setting the values via either
setValue() or push().

That said, given <s:action.../> I'm not sure I see a
huge advantage to doing so; I was thinking about this
several months ago and was unsure if the (slight)
extra work to do this in a preparer was really worth
it.

Does anybody have any thoughts regarding the value of
Tiles view preparers in an S2 environment? To me
(right now, at least) it seems like extra work,
another API to deal with, (potential) synchronization
issues, etc., since I already have a lot of the
functionality built-in to S2.

Thanks,
Dave

--- Dave Newton <ne...@yahoo.com> wrote:
> --- stanlick@gmail.com wrote:
> > Antonio --
> 
> Not directed towards me so I'm somewhat hesitant to
> answer given responses in the past, but:
> 
> ./views/jsp/TagUtils.java:        
> ValueStack stack = (ValueStack) 
>
req.getAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY);
> 
> Perhaps the stack is accessible from within the
> request, but I cannot test this at the moment.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles 2 woes

Posted by Dave Newton <ne...@yahoo.com>.
--- stanlick@gmail.com wrote:
> Antonio --

Not directed towards me so I'm somewhat hesitant to
answer given responses in the past, but:

./views/jsp/TagUtils.java:        
ValueStack stack = (ValueStack) 
req.getAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY);

Perhaps the stack is accessible from within the
request, but I cannot test this at the moment.

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org