Results 1 to 3 of 3

Thread: Themes & I18N App

  1. #1
    Join Date
    Dec 2011
    Posts
    6

    Default Themes & I18N App

    dispatcher-servlet.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    		xmlns:p="http://www.springframework.org/schema/p"
    		xmlns:jee="http://www.springframework.org/schema/jee"
    		xmlns:context="http://www.springframework.org/schema/context"
    		xmlns:mvc="http://www.springframework.org/schema/mvc"
    		xsi:schemaLocation="http://www.springframework.org/schema/beans
    		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    		http://www.springframework.org/schema/context
    		http://www.springframework.org/schema/context/spring-context-3.0.xsd
    		http://www.springframework.org/schema/mvc
    		http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
    		
    	<bean id="viewResolver"
    		class="org.springframework.web.servlet.view.InternalResourceViewResolver"
    		p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
        
        <mvc:annotation-driven/>
        <context:component-scan base-package="com.netsol" />
      
      	<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    		<property name="basename" value="classpath:messages" />
    	</bean>
    
        <!--  <jee:jndi-lookup id="myDataSource" jndi-name="java:comp/env/jdbc/globalDataSource" /> -->
    	<bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
          <property name="jndiName" value="java:comp/env/jdbc/myGlobalDataSource"/>   
          <property name="resourceRef" value="true" />
    	</bean>
    	   
    	<!-- <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    		<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    		<property name="url" value="jdbc:mysql://192.168.0.240:3306/demo"/>
    		<property name="username" value="java"/>
    		<property name="password" value="JavA_123#"/>
    	</bean> -->
    	
    	<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    		<property name="dataSource" ref="myDataSource"/>
    		<property name="annotatedClasses">
            <list>
                <value>com.netsol.domain.User</value>
            </list>
        </property>
    		<property name="hibernateProperties">
    			<props>
    			   <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
    			   <prop key="hibernate.show_sql">true</prop>
    			   <prop key="hibernate.hbm2ddl.auto">createOrUpdate</prop>
    		    </props>
    		</property>
    	</bean>
    	
    	<bean id="userDAOImpl" class="com.netsol.dao.UserDAOImpl">
    		<property name="sessionFactory" ref="mySessionFactory" />
    	</bean>
    	<bean id="userController" class="com.netsol.web.UserController">
    		<property name="userDAO" ref="userDAOImpl" />
    	</bean>
    	
    	<bean id="localeChangeInterceptor"	class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
    		<property name="paramName" value="lang" />
    	</bean>
    	
    	<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
            <property name="defaultLocale" value="en" />
        </bean>
    
    		
    	<bean id="themeSource"	class="org.springframework.ui.context.support.ResourceBundleThemeSource">
    		<property name="basenamePrefix" value="theme-" />
    	</bean>
    
    	<!-- Theme Change Interceptor and Resolver definition -->
    	<bean id="themeChangeInterceptor"
    		class="org.springframework.web.servlet.theme.ThemeChangeInterceptor">
    		<property name="paramName" value="theme" />
    	</bean>
    	<bean id="themeResolver"
    		class="org.springframework.web.servlet.theme.CookieThemeResolver">
    		<property name="defaultThemeName" value="default" />
    	</bean>
    
    	<bean id="handlerMapping"
    		class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
    		<property name="interceptors">
    			<list>
    				<ref bean="localeChangeInterceptor" />
    				<ref bean="themeChangeInterceptor" />
    			</list>
    		</property>
    	</bean>
    	<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    		<property name="interceptors">
    			<list>
    				<ref bean="localeChangeInterceptor" />
    				<ref bean="themeChangeInterceptor" />
    			</list>
    		</property>
    		
    		</bean>
    </beans>

    userform.jsp
    Code:
    <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
    <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>  
    <html>
    <head>
    <title>Registration Page</title>
    </head>
    <body>
    
    <span style="float: right">
        <a href="?lang=en">English</a>
        |
        <a href="?lang=de">German</a>
    </span>
     
    <span style="float: left">
        <a href="?theme=default">Default</a>
        |
        <a href="?theme=Grey">Grey</a>
        |
        <a href="?theme=Red">Red</a>
        |
        <a href="?theme=Green">Green</a>
    </span>
    <form:form method="POST" action="userRegistration.htm" commandName="user">
    	<table>
    		<tr>
    			<td><form:label path="userName">
    					<spring:message code="label.userName" />
    				</form:label><font color="red">
    				<form:errors path="userName" /></font>
    			</td>
    			<td><form:input path="userName" /></td>
    		</tr>
    		<tr>
    			<td><form:label path="password">
    					<spring:message code="label.password" />
    				</form:label>
    				<font color="red"><form:errors path="password" /></font>
    			</td>
    			<td><form:password path="password" /></td>
    		</tr>
    		<tr>
    			<td><form:label path="gender">
    					<spring:message code="label.gender" />
    				</form:label><font color="red">
    				<form:errors path="gender" /></font>
    			</td>
    			<td><form:radiobutton path="gender" value="M" label="M" /> <form:radiobutton
    				path="gender" value="F" label="F" /></td>
    		</tr>
    	
    		<tr>
    			<td>About you :<font color="red"><form:errors path="aboutYou" /></font></td>
    			<td><form:textarea path="aboutYou" /></td>
    		</tr>
    		<%-- <tr>
    			<td>Community :</td>
    			<td><form:checkboxes path="communityList" items="${communityList}" itemValue="key" itemLabel="value" /></td>
    		</tr> --%>
    		<tr>
    			<td></td>
    			<td><form:checkbox path="mailingList"
    				label="Would you like to join our mailinglist?" /></td>
    		</tr>
    		<tr>
    			<td colspan="2"><input type="submit"></td>
    		</tr>
    	</table>
    </form:form>
    
    </body>
    </html>

    when i click on any link for change to my theme or language then its not working,, i have placed my .css files under WebContent directory of Eclipse IDE and respective properties file under classes folder ,, its my first application of theme and i18n so plzz help me go forward,,
    Last edited by java.gagan; Dec 29th, 2011 at 09:30 PM.

  2. #2

    Default

    Hi,
    when it's working, what is your issue?

  3. #3
    Join Date
    Dec 2011
    Posts
    6

    Default

    sorry by mistake i wrote working its not working,,
    When i click on any link in JSP relate to theme change or Language change den it wont work,, This is my first application of I18N & theme change i have done all the steps according to sample example but still i m nt getting any effect of it,,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •