• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

struts2 problem

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am unable to populate modeldriven bean from jsp form in struts2.0 Action class.In Action class the bean is giving empty values.if i remove the interceptors from stuts.xml, then i am able to get values in Action class from jsp.But i need to use interceptors and also need data from my form using model driven concept. I am struggling to find the root cause.

I integrated struts , spring and hibernate.

my struts.xml
-----------------

<package name="default" namespace="/" extends="struts-default">
<result-types>
<result-type name="tiles"
class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>

<interceptors>
<interceptor name="authenticator" class="com.sample.interceptors.MyLoggingInterceptor"/>
<interceptor-stack name="prime-stack">
<interceptor-ref name="authenticator"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>

<default-interceptor-ref name="defaultStack"/>

<action name="signin" class="loginAction" method="login">
<interceptor-ref name="authenticator"/>
<result name="success" type="tiles">login_success</result>
<result name="fail" type="tiles">errors</result>
<result name="input" type="tiles">login</result>
</action>
</package>

my applicationContext.xml
-------------------------------

<bean id="loginAction" class="com.sample.actions.LoginAction" scope="prototype">
<property name="objUserLoginService" ref="loginserviceref"/>
</bean>

<bean id="loginserviceref" class="com.sample.services.UserLoginService">
<property name="objUserLoginDao" ref="logindaoref"></property>
</bean>

<bean id="logindaoref" class="com.sample.daos.UserLoginDao">
<property name="sessionFactory" ref="mySessionFactory"/>
</bean>




my Action Class
--------------------

public class LoginAction extends ActionSupport implements ModelDriven{

private User objUser = new User();

public Object getModel() {
return objUser;
}

public String login() {

try {

System.out.println("username-->" + objUser.getStrUser_Name()); // I am unable to get my login form data from login.jsp while
// using interceptors
System.out.println("password-->" + objUser.getStrUser_Password()); // I am unable to get my login form data from login.jsp
} catch(Exception e) {
}
return "success";
}



Thanks in Advance
 
Ranch Hand
Posts: 188
Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi anil,
<interceptor-ref name="authenticator"/>
put
 
I'd appreciate it if you pronounced my name correctly. Pinhead, with a silent "H". Petite ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic