reset password
Author Message
mbhatt
Posts: 14
Posted 12:16 May 07, 2009 |

Can i find some example or material which explains using  theme resolvers in spring...

 

i.e some example of

org.springframework.ui.context.support.ResourceBundleThemeSource

and

org.springframework.web.servlet.theme.SessionThemeResolver

I am aware of these classes..

just confused where to put my themes.properties file

and how to get that file using
ResourceBundleThemeSource

i.e
in following code
<bean id="themeSource" class="org.springframework.ui.context.support.ResourceBundleThemeSource">
<property name="basenamePrefix" value="package.name."/>
</bean>

package.name should be my theme package..?
Last edited by mbhatt at 12:21 May 07, 2009.
cysun
Posts: 2935
Posted 13:30 May 07, 2009 |

You don't need to use Theme support in Spring. For our simple purpose, you can just create two CSS and pick one to use based on user's theme choice.

Last edited by cysun at 13:31 May 07, 2009.
yurimuradyan
Posts: 42
Posted 14:18 May 07, 2009 |
cysun wrote:

You don't need to use Theme support in Spring. For our simple purpose, you can just create two CSS and pick one to use based on user's theme choice.

I have locations for the css files stored in a table and Blog has a property called theme_id, linking it to the table. Issue I am having is, creating a dropdown from the themes table, but populating the selection into the blog table's theme_id property. Does anyone have an idea on how to do this?

Thanks!

cysun
Posts: 2935
Posted 14:23 May 07, 2009 |
yurimuradyan wrote:
cysun wrote:

You don't need to use Theme support in Spring. For our simple purpose, you can just create two CSS and pick one to use based on user's theme choice.

I have locations for the css files stored in a table and Blog has a property called theme_id, linking it to the table. Issue I am having is, creating a dropdown from the themes table, but populating the selection into the blog table's theme_id property. Does anyone have an idea on how to do this?

Thanks!

I don't want to give the answer, but feel free to discuss.

yurimuradyan
Posts: 42
Posted 18:48 May 07, 2009 |

Figured out my first issue (I was trying to map an integer to an object).

Here is a problem that is actually getting in the way of things. In my implementation Theme is a class and Blog is another class. Blog has a "theme" field, which is obviously a Theme. Now when I try to set this on the form I canno, since form supports only 1 command object. Does anyone know a workaround to this issue??

 

cysun
Posts: 2935
Posted 20:17 May 07, 2009 |
yurimuradyan wrote:

Figured out my first issue (I was trying to map an integer to an object).

Here is a problem that is actually getting in the way of things. In my implementation Theme is a class and Blog is another class. Blog has a "theme" field, which is obviously a Theme. Now when I try to set this on the form I canno, since form supports only 1 command object. Does anyone know a workaround to this issue?? 

You can't set a Theme object, but you can set a themeId parameter, and get that parameter from HttpRequest in onSubmit().

yurimuradyan
Posts: 42
Posted 08:36 May 08, 2009 |
cysun wrote:
yurimuradyan wrote:

Figured out my first issue (I was trying to map an integer to an object).

Here is a problem that is actually getting in the way of things. In my implementation Theme is a class and Blog is another class. Blog has a "theme" field, which is obviously a Theme. Now when I try to set this on the form I canno, since form supports only 1 command object. Does anyone know a workaround to this issue?? 

You can't set a Theme object, but you can set a themeId parameter, and get that parameter from HttpRequest in onSubmit().

I did not even think of it. Thanks Dr. Sun, that helped a lot!

jadiagaurang
Posts: 53
Posted 02:07 May 11, 2009 |

Hello All,

I tried to finish theme part in my homework but, could not finish in time. I did not submit it also because of few run time errors. But, I am just wondering that what is correct approch to implement themes. It is by making Theme Calss and use it as Blog proterty or by using Spring Theme Resolver?

I have question that Should we validate size of blog image (image URL or image file). When I give URL of small image then it displays fine but, when I give URL of large image then whole layout is messed up. I think we should validate size of blog image. I am also wondering that every blog should have RSS or some sharing feature. Should we use some external library like ROME or else for the same? Any more suggestions?

cysun
Posts: 2935
Posted 10:55 May 11, 2009 |
jadiagaurang wrote:

Hello All,

I tried to finish theme part in my homework but, could not finish in time. I did not submit it also because of few run time errors. But, I am just wondering that what is correct approch to implement themes. It is by making Theme Calss and use it as Blog proterty or by using Spring Theme Resolver?

For homework you don't need to use Spring Theme Resolver because in our case a "theme" is just one CSS file. You don't need to create a Theme class either. An additional theme field in the Blog class should be enough.

For more comprehensive Theme support in a real application, you should consider using Spring Theme support. It allows you to specify multiple resources (e.g. style sheets, images, messages and so on) for a theme, supports locale, and provides a ThemeChangeInterceptor so you don't have to write theme changing code yourself.

I have question that Should we validate size of blog image (image URL or image file). When I give URL of small image then it displays fine but, when I give URL of large image then whole layout is messed up. I think we should validate size of blog image. I am also wondering that every blog should have RSS or some sharing feature. Should we use some external library like ROME or else for the same? Any more suggestions?

In a real application you should resize the user images to the right dimension, but you don't need to do that for the homework. In either case, you may want to use the width and height attribute of <img> to make sure it doesn't mess up the layout.

We'll talk about RSS later in class.

Last edited by cysun at 10:56 May 11, 2009.