anil kumar mullapudi

Greenhorn
+ Follow
since Oct 25, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by anil kumar mullapudi

Autocomplete is not working for me, my control goes upto Action class, After that my autocomplete is not getting data from my Action class to jsp page.

jsp page
------------

<s:url id="searchURL" action="searchActionJSON" />

<sx:autocompleter size="24" label="User"
name="strUser_Name" href="%{searchURL}" autoComplete="true"
loadOnTextChange="true" loadMinimumCount="1"></sx:autocompleter>


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

<action name="searchActionJSON" class="manageUserAction" method="searchActionJSON">
<result type="json">
<param name="root">json</param>
</result>
</action>


action class
------------

public String searchActionJSON() {
System.out.println("---------search val-------->" + objUser.getStrUser_Name());

json = new HashMap<String, String>();

if (objUser.getStrUser_Name() != null && objUser.getStrUser_Name().length() > 0) {

System.out.println("********inside if**********"); // control comes upto here
json.put("1", "apple");
json.put("2", "banana");
json.put("3", "orange");
}
return "success";
}

the above json variable has setter and getters

when i type a letter in my autocomplete combo box , that letter comes to action class.But after that data is not coming to my jsp.
Please help me, how to find the root cause.

Thanks,
Anil
13 years ago
Problem solved when i remove the setters in my Action class which are injected from spring configuration file.
Instead of setter injection i used constructor injection, Now everything works fine, But my action class method executes two times for a single request. I am unable to stop this second time execution.
13 years ago
i have a ArrayList "objUsersList" in my Action class. That contains the following data.

objUsersList has setters and getters in my Action class.

[User [Nuser_id=1, strUser_FirstName=anil, strUser_LastName=mullapudi, strUser_Name=anil, strUser_Password=root, strUser_gender=M],
User [Nuser_id=2, strUser_FirstName=Ramesh, strUser_LastName=gubbala, strUser_Name=ramesh, strUser_Password=root, strUser_gender=M],
User [Nuser_id=3, strUser_FirstName=anil, strUser_LastName=vatti, strUser_Name=anilv, strUser_Password=root, strUser_gender=M],
User [Nuser_id=4, strUser_FirstName=ram, strUser_LastName=m, strUser_Name=ram, strUser_Password=root, strUser_gender=M],
User [Nuser_id=5, strUser_FirstName=tarun, strUser_LastName=k, strUser_Name=tarun, strUser_Password=root, strUser_gender=m]]


I am using the following code in my jsp.
java script:
-------------
function viewUsers() {

var url = 'view_users.action';

var myAjax = new Ajax.Request(
url,
{
method: 'post',
onComplete: fetchUsers
});

}

function fetchUsers(originalRequest) {
var result = originalRequest.responseText.evalJSON(); // the execution stops here
alert(result.objUsersList[0]);
}

How to populate my ArrayList in my jsp page. Please help me.



I changed the above code to

function fetchUsers(originalRequest) {
alert(originalRequest.responseText);
}

Then i got the following execption in alert message


<html><head><title>Apache Tomcat/6.0.10 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: java.lang.reflect.InvocationTargetException
com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:239)
com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:161)
com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:127)
com.googlecode.jsonplugin.JSONWriter.write(JSONWriter.java:95)
com.googlecode.jsonplugin.JSONUtil.serialize(JSONUtil.java:98)
com.googlecode.jsonplugin.JSONResult.execute(JSONResult.java:179)
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:361)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:265)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)
com.opensymphony…

Thanks in advance.
Anil ([email protected])
13 years ago
i have a ArrayList "objUsersList" in my Action class. That contains the following data.

objUsersList has setters and getters in my Action class.

[User [Nuser_id=1, strUser_FirstName=anil, strUser_LastName=mullapudi, strUser_Name=anil, strUser_Password=root, strUser_gender=M],
User [Nuser_id=2, strUser_FirstName=Ramesh, strUser_LastName=gubbala, strUser_Name=ramesh, strUser_Password=root, strUser_gender=M],
User [Nuser_id=3, strUser_FirstName=anil, strUser_LastName=vatti, strUser_Name=anilv, strUser_Password=root, strUser_gender=M],
User [Nuser_id=4, strUser_FirstName=ram, strUser_LastName=m, strUser_Name=ram, strUser_Password=root, strUser_gender=M],
User [Nuser_id=5, strUser_FirstName=tarun, strUser_LastName=k, strUser_Name=tarun, strUser_Password=root, strUser_gender=m]]


I am using the following code in my jsp.
java script:
-------------
function viewUsers() {

var url = 'view_users.action';

var myAjax = new Ajax.Request(
url,
{
method: 'post',
onComplete: fetchUsers
});

}

function fetchUsers(originalRequest) {
var result = originalRequest.responseText.evalJSON(); // the execution stops here
alert(result.objUsersList[0]);
}

How to populate my ArrayList in my jsp page. Please help me.

Thanks in advance.

I changed the above code to

function fetchUsers(originalRequest) {
alert(originalRequest.responseText);
}

Then i got the following execption in alert message


<html><head><title>Apache Tomcat/6.0.10 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: java.lang.reflect.InvocationTargetException
com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:239)
com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:161)
com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:127)
com.googlecode.jsonplugin.JSONWriter.write(JSONWriter.java:95)
com.googlecode.jsonplugin.JSONUtil.serialize(JSONUtil.java:98)
com.googlecode.jsonplugin.JSONResult.execute(JSONResult.java:179)
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:361)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:265)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)
com.opensymphony…



13 years ago

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

<action name="view_users" class="manageUserAction" method="getViewUsers">
<interceptor-ref name="defaultStack">
<param name="validation.excludeMethods">getViewUsers</param>
</interceptor-ref>
<interceptor-ref name="authenticator" />
<interceptor-ref name="actionexectime" />
<result name="success">/jsp/ajaxresult.jsp</result>
<result name="fail" type="tiles">Fail.jsp</result>
<result name="input" type="tiles">LoginSuccess.jsp</result>
<result name="login" type="tiles">login.jsp</result>
</action>

tiles.xml
----------

<definition name="baseLayout" template="/Layouts/baseLayout.jsp">
<put-attribute name="title" value="Template" />
<put-attribute name="header" value="/Layouts/header.jsp" />
<put-attribute name="menu" value="/Layouts/menu.jsp" />
<put-attribute name="body" value="/Layouts/body.jsp" />
<put-attribute name="footer" value="/Layouts/footer.jsp" />
</definition>


<definition name="*.*" extends="baseLayout">
<put-attribute name="title" value="{1}" />
<put-attribute name="body" value="/{2}/{1}.jsp" />
</definition>



Now i typed the url "http://localhost:8080/MyApp/home",
From my home page "home.jsp" i clicked "view_user" button , In on click of this "view_user" button i sent a ajax request for displaying list of employees.This ajax request goes to "view_users" action in struts.xml file. And i got response text from "/jsp/ajaxresult.jsp" to my home.jsp.

As of now the above code working fine. The problem is in the url if i directly type this "view_users" action like "http://localhost:8080/MyApp/view_users" i got result in a separate page, the tiles functionality is not working here.

i want to work this in both different url as mentioned above should be same,Is it possible, Any idea in this please help me.
13 years ago

my tiles.xml
---------------
<definition name="baseLayout" template="/Layouts/baseLayout.jsp">
<put-attribute name="title" value="Template"/>
<put-attribute name="header" value="/Layouts/header.jsp"/>
<put-attribute name="menu" value="/Layouts/menu.jsp"/>
<put-attribute name="body" value="/Layouts/body.jsp"/>
<put-attribute name="footer" value="/Layouts/footer.jsp"/>
</definition>

<definition name="welcome" extends="baseLayout">
<put-attribute name="title" value="Welcome"/>
<put-attribute name="body" value="/Layouts/welcome.jsp"/>
</definition>

in my struts.xml file i have so many result pages, so i need write tiles definitions for each result page. And every time i want to change only body page of my base layout. Is it possible with one tiles definition for all results and if possible how to pass our dynamic result page to that body tile definitions in tiles.xml file.
13 years ago
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
13 years ago
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";
}






13 years ago