Thanks Again Lance.

On Wed, Mar 28, 2012 at 12:10 PM, Lance Java <lance.j...@googlemail.com>wrote:

> I was assuming that all of your links were rendered by Tapestry (eg
> EventLink and ActionLink). If this was the case then it *should* just work.
>

You are assuming well. I am using ActionLinks.
Right now, When you click a link I am doing:
"return Page.class;"
But as far as I understood, now I will have to do something like:
*@Inject Enviroment*

and instead of return do some stuff like:

*return(pageRender.createPageRenderLink(FBAssociationPage.class)+
".facebookloginlink");*

adding the getMode() somewhere in there...

So it seems I am not understanding very well how to use the @Enviroment. Or
this is what I have to do?

Thanks.


> On Wednesday, 28 March 2012, Juan Alba <juan.a...@condortech.com.ar>
> wrote:
> > First of all, thanks again Lance!
> >
> >
> >
> > On Wed, Mar 28, 2012 at 11:25 AM, Lance Java <lance.j...@googlemail.com
> >wrote:
> >
> >> Perhaps this would work
> >>
> >> Create an environmental object called Mode
> >>
> >> public interface Mode {
> >>   public String getMode(); // facebook or normal
> >> }
> >>
> >> Use tapestry's URL rewriting to rewrite http://myapp/facebook/page to
> >> http://myapp/page (see
> >> http://blog.tapestry5.de/index.php/2010/09/06/new-url-rewriting-api/)
> >>
> >> As the URL is rewritten, it pushes a mode onto the environment (either
> >> "facebook" or "normal")
> >>
> >>   @Inject
> >>   Environment environment
> >>
> >>   String mode = getModeFromURL();
> >>   environment.push(Mode.class, new ModeImpl(mode));
> >>
> >
> > This is great and I think that I'd got it.
> >
> > The problem is with this second part:
> >
> >> When rendering links, use Environment.peek() to get the Mode from the
> >> environment and add the mode to each link URL if necessary.
> >>
> >> Components and Pages can then use the @Environmental annotation to
> inject
> >> the mode to determine which styles to include
> >>
> >> Then you get normal browsers to access http://myapp/page and facebook
> to
> >> access http://myapp/facebook/page
> >>
> >>
> > My web app is using a lot of webLibs (almost one per section). If I do
> > this, I will have to change all the web app, and all the web libs to
> > build the links correctly? It seems to be a huge re-factoring.
> >
> > I am getting the idea right?
> >
> > Thanks.
> >
> >
> >
> >
> >> On Wednesday, 28 March 2012, Juan Alba <juan.a...@condortech.com.ar>
> >> wrote:
> >> > Thanks Bob and Lance for the ideas and recomendations.
> >> > I think that Lance understood better my problem. The mode to change
> the
> >> css
> >> > I have it already solved with Thiago's suggestion.
> >> > Now my problem is that I can't define which stylesheet to use from
> >> server's
> >> > side because the only way to define it is knowing if the app is
> running
> >> on
> >> > an iframe or not.
> >> >
> >> > Before sending the mail with my problems I tried to use either
> >> suggestions
> >> > "Parameter" and "Cookies or Session".
> >> >
> >> > *Parameter:*
> >> > If I have the parameter I have to change every class in the webapp to
> add
> >> > the parameter if is set and don't loose it after the first link hit.
> >> >
> >> > *Cookies or Session:*
> >> > If they are set, It seems to work fine until I close the application
> >> > running in the iframe and open it in a new browser. It keeps all the
> >> > session or cookies and will use the wrong stylesheet.
> >> >
> >> > Any other idea?
> >> >
> >> > Thanks guys.
> >> >
> >> > On Wed, Mar 28, 2012 at 4:31 AM, Lance Java <
> lance.j...@googlemail.com
> >> >wrote:
> >> >
> >> >> All of the solutions mentioned on this thread assume that there is a
> way
> >> >> ofdetermining which "mode" your pages/components need to include
> styles
> >> >> for.
> >> >>
> >> >> From what you have said, it seems that you currently only know the
> >> "mode"
> >> >> clientside in javascript.
> >> >>
> >> >> I get the feeling that you may need to re-think your design slightly
> so
> >> >> that the "mode" is known on the serverside. This can be done by
> >> activation
> >> >> context, request parameter, URL, cookie, session attribute etc.
> >> >>
> >> >> On Tuesday, 27 March 2012, Juan Alba <juan.a...@condortech.com.ar>
> >> wrote:
> >> >> > Thanks for your help guys, now I am realizing that my real problem
> is
> >> >> > another one. It concerns more with the logic to know what style to
> >> load.
> >> >> >
> >> >> > My app can be used in the browser (regular way) or also as a
> Facebook
> >> >> App.
> >> >> > This means an iframe where everything is smaller, and the
> backgrounds
> >> >> need
> >> >> > to be similar to the one in Facebook (so it looks nicer).
> >> >> > I have done something in javascript to realize if the app is being
> >> used
> >> >> > embebed or used "regular way". But this is reloading all the styles
> so
> >> I
> >> >> > have a first sight of the default tapestry styles and then the new
> >> ones
> >> >> > (not nice at all), and there are some problems with the components
> >> >> styles,
> >> >> > so the solution is not really a good one.
> >> >> >
> >> >> > I am wondering if there is a css strategy or some way to load the
> >> style
> >> >> > according to where from I am visiting the app, regular way or
> >> facebook.
> >> >> >
> >> >> >
> >> >> > Thanks in advance for all your help.
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> > On Tue, Mar 27, 2012 at 4:52 AM, Lance Java <
> >> lance.j...@googlemail.com
> >> >> >wrote:
> >> >> >
> >> >> >> Tapestry uses the ImportWorker to process @Import annotations
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >>
> >>
>
> http://tapestry.apache.org/5.3/apidocs/src-html/org/apache/tapestry5/internal/transform/ImportWorker.html
> >> >> >>
> >> >> >> You could quite easily write your own annotation (and worker) to
> do a
> >> >> >> similar job with your custom logic
> >> >> >
>

Reply via email to