You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Adam Ruggles <a....@gmail.com> on 2009/03/31 04:35:26 UTC

Skinning, themeing with stuts 2.1.x and the convention plugin

I'm looking for a way using the convention plugin to support custom
themes/skins for a web page.  Right now I can't really see a good way to
implement this using struts2.
-- 
View this message in context: http://www.nabble.com/Skinning%2C-themeing-with-stuts-2.1.x-and-the-convention-plugin-tp22797203p22797203.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Skinning, themeing with stuts 2.1.x and the convention plugin

Posted by Adam Ruggles <a....@gmail.com>.
It's definitely more  than just css changes.

I like the idea of creating my own result type.  I'm already defining my own
interceptor stack so that should be relatively simple to implement.

Thanks.


Musachy Barroso wrote:
> 
> If the changes are just CSS-releated, the you just need to save the
> selected "theme" name in a cookie, and then link to the appropriate
> CSS file in Sitemesh, or whatever it is you are using that outputs the
> header.
> 
> If you need to have different jsps for the different themes, then the
> easiest thing you can do(I think) is to add @Result annotations to
> your actions like(the advantages of Convention start to fade away in
> this case):
> 
> @Result(location="${theme}/mypage.jsp")
> 
> and have a getTheme() in your actions, or something like that. Where
> the theme is retrieved from a  cookie, or the session, or a parameter.
> 
> Another third option, is to write your own result that extends
> ServletDispatcherResult, and instead of just dispatching, it changes
> the request URL (the path of the jsp), to point to the appropriate jsp
> inside the current theme (again from cookie, session, etc). Then you
> can either use this result directly (type="mynewresult"), or you can
> create your own interceptor stack, and apply it your actions, where
> "dispatcher" points to your own result, instead of
> ServletDispatcherResult. This option is longer, but your action will
> look cleaner.
> 
> musachy
> 
> On Tue, Mar 31, 2009 at 10:51 AM, Adam Ruggles <a....@gmail.com>
> wrote:
>>
>> Hi Pawel,
>>
>> Thanks for your response.  What I'm looking for is a user selectable
>> skin/theme for the look and feel of a website.  One example would be a
>> user
>> goes to /theme1/home/index and the jsp page for theme1 for home/index is
>> used to render the page.  If the user goes to /theme2/home/index a
>> different
>> jsp page located in theme2 is used to render the page.    Both pages
>> should
>> be backed by the same action bean.  I'm not tied to an url
>> implementation, I
>> wouldn't mind storing the theme in a persistent storage or passed in as a
>> parameter as well.
>>
>> So far the only kind of solutions I've seen for struts will not work with
>> the conventions plugin or they require sitemesh.  I'd prefer a more
>> struts2
>> solution.
>>
>> Thanks,
>> Adam
>>
>>
>> Paweł Wielgus wrote:
>>>
>>> Hi Adam,
>>> could You tell a little more about how would you like to use
>>> convention for templating?
>>> Also check the other thread about this subject, that was on the list
>>> feew days (maybe weeks) ago.
>>>
>>> Best greetings,
>>> Pawel Wielgus.
>>>
>>> 2009/3/31, Adam Ruggles <a....@gmail.com>:
>>>>
>>>> I'm looking for a way using the convention plugin to support custom
>>>> themes/skins for a web page.  Right now I can't really see a good way
>>>> to
>>>> implement this using struts2.
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Skinning%2C-themeing-with-stuts-2.1.x-and-the-convention-plugin-tp22797203p22797203.html
>>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Skinning%2C-themeing-with-stuts-2.1.x-and-the-convention-plugin-tp22797203p22804974.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 
> 
> -- 
> "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Skinning%2C-themeing-with-stuts-2.1.x-and-the-convention-plugin-tp22797203p22808170.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Skinning, themeing with stuts 2.1.x and the convention plugin

Posted by Musachy Barroso <mu...@gmail.com>.
If the changes are just CSS-releated, the you just need to save the
selected "theme" name in a cookie, and then link to the appropriate
CSS file in Sitemesh, or whatever it is you are using that outputs the
header.

If you need to have different jsps for the different themes, then the
easiest thing you can do(I think) is to add @Result annotations to
your actions like(the advantages of Convention start to fade away in
this case):

@Result(location="${theme}/mypage.jsp")

and have a getTheme() in your actions, or something like that. Where
the theme is retrieved from a  cookie, or the session, or a parameter.

Another third option, is to write your own result that extends
ServletDispatcherResult, and instead of just dispatching, it changes
the request URL (the path of the jsp), to point to the appropriate jsp
inside the current theme (again from cookie, session, etc). Then you
can either use this result directly (type="mynewresult"), or you can
create your own interceptor stack, and apply it your actions, where
"dispatcher" points to your own result, instead of
ServletDispatcherResult. This option is longer, but your action will
look cleaner.

musachy

On Tue, Mar 31, 2009 at 10:51 AM, Adam Ruggles <a....@gmail.com> wrote:
>
> Hi Pawel,
>
> Thanks for your response.  What I'm looking for is a user selectable
> skin/theme for the look and feel of a website.  One example would be a user
> goes to /theme1/home/index and the jsp page for theme1 for home/index is
> used to render the page.  If the user goes to /theme2/home/index a different
> jsp page located in theme2 is used to render the page.    Both pages should
> be backed by the same action bean.  I'm not tied to an url implementation, I
> wouldn't mind storing the theme in a persistent storage or passed in as a
> parameter as well.
>
> So far the only kind of solutions I've seen for struts will not work with
> the conventions plugin or they require sitemesh.  I'd prefer a more struts2
> solution.
>
> Thanks,
> Adam
>
>
> Paweł Wielgus wrote:
>>
>> Hi Adam,
>> could You tell a little more about how would you like to use
>> convention for templating?
>> Also check the other thread about this subject, that was on the list
>> feew days (maybe weeks) ago.
>>
>> Best greetings,
>> Pawel Wielgus.
>>
>> 2009/3/31, Adam Ruggles <a....@gmail.com>:
>>>
>>> I'm looking for a way using the convention plugin to support custom
>>> themes/skins for a web page.  Right now I can't really see a good way to
>>> implement this using struts2.
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Skinning%2C-themeing-with-stuts-2.1.x-and-the-convention-plugin-tp22797203p22797203.html
>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Skinning%2C-themeing-with-stuts-2.1.x-and-the-convention-plugin-tp22797203p22804974.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: Skinning, themeing with stuts 2.1.x and the convention plugin

Posted by Adam Ruggles <a....@gmail.com>.
Hi Pawel,

Thanks for your response.  What I'm looking for is a user selectable
skin/theme for the look and feel of a website.  One example would be a user
goes to /theme1/home/index and the jsp page for theme1 for home/index is
used to render the page.  If the user goes to /theme2/home/index a different
jsp page located in theme2 is used to render the page.    Both pages should
be backed by the same action bean.  I'm not tied to an url implementation, I
wouldn't mind storing the theme in a persistent storage or passed in as a
parameter as well.

So far the only kind of solutions I've seen for struts will not work with
the conventions plugin or they require sitemesh.  I'd prefer a more struts2
solution.

Thanks,
Adam


Paweł Wielgus wrote:
> 
> Hi Adam,
> could You tell a little more about how would you like to use
> convention for templating?
> Also check the other thread about this subject, that was on the list
> feew days (maybe weeks) ago.
> 
> Best greetings,
> Pawel Wielgus.
> 
> 2009/3/31, Adam Ruggles <a....@gmail.com>:
>>
>> I'm looking for a way using the convention plugin to support custom
>> themes/skins for a web page.  Right now I can't really see a good way to
>> implement this using struts2.
>> --
>> View this message in context:
>> http://www.nabble.com/Skinning%2C-themeing-with-stuts-2.1.x-and-the-convention-plugin-tp22797203p22797203.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Skinning%2C-themeing-with-stuts-2.1.x-and-the-convention-plugin-tp22797203p22804974.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Skinning, themeing with stuts 2.1.x and the convention plugin

Posted by Paweł Wielgus <po...@gmail.com>.
Hi Adam,
could You tell a little more about how would you like to use
convention for templating?
Also check the other thread about this subject, that was on the list
feew days (maybe weeks) ago.

Best greetings,
Pawel Wielgus.

2009/3/31, Adam Ruggles <a....@gmail.com>:
>
> I'm looking for a way using the convention plugin to support custom
> themes/skins for a web page.  Right now I can't really see a good way to
> implement this using struts2.
> --
> View this message in context:
> http://www.nabble.com/Skinning%2C-themeing-with-stuts-2.1.x-and-the-convention-plugin-tp22797203p22797203.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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