This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

How to render json response in jsp page using jquery-struts2 plugin

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am new to struts2 framework.Please help to solve this problem.

I am using Jquery-struts2 plugin in my jsp. i want populate div element but that div displays it's content using struts2 default tag like <s:textfield> or <s:property>

[code]

<s:url action="testaction" var="v1"/>
<sj:div href="%{v1}" id="test" reloadTopics="comboselected">
<s:property value="testStr"/>
</sj:div>

[code]

when i run this program, my jsp page get's json response and it display it as {"testStr":"value sent from action"} .

I tries to replace s:property with s:textfiled but textfiled value is not displayed..

My Action class has getter and setter and corresponding action return json type as well.

I am not getting what is wrong in my program. and no error are shown. or we should not use struts default tag in ajax div tag.

Please suggest me something on this. or atleast point me to correct document.

Thanks.

 
Bartender
Posts: 9588
13
Mac OS X Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

pinky deshmukh wrote:
I tries to replace s:property with s:textfiled but textfiled value is not displayed..



That's because your original code isn't displaying the JSON value in the property tag, it's replacing whatever is in the DIV with the value from the AJAX call.
Are you familiar with jQuery and AJAX? You can save yourself a lot of frustration by starting here and getting the basics down before trying to piece together components you don't understand.
 
pinky deshmukh
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Joe Ess wrote:

pinky deshmukh wrote:
I tries to replace s:property with s:textfiled but textfiled value is not displayed..



That's because your original code isn't displaying the JSON value in the property tag, it's replacing whatever is in the DIV with the value from the AJAX call.
Are you familiar with jQuery and AJAX? You can save yourself a lot of frustration by starting here and getting the basics down before trying to piece together components you don't understand.




Thanks Joe, Yes i am new to jquery. I am familiar with AJAX.
Does it mean i must write code(in jquery) to populate property in jsp from json response? or is there anything i am missing in my configuration..

 
pinky deshmukh
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Joe Ess wrote:

pinky deshmukh wrote:
I tries to replace s:property with s:textfiled but textfiled value is not displayed..



That's because your original code isn't displaying the JSON value in the property tag, it's replacing whatever is in the DIV with the value from the AJAX call.
Are you familiar with jQuery and AJAX? You can save yourself a lot of frustration by starting here and getting the basics down before trying to piece together components you don't understand.




Hi Joee,

I have tried above link and using parseJSON method of jquery to render my response. but i am still not getting the correct result.

whenever i tried to debug it , i could see all my values in response but still not able to parse it. PLease suggest some method or give me some example code or link.

Thanks
 
Joe Ess
Bartender
Posts: 9588
13
Mac OS X Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show us some code that exhibits this behavior (preferably a Short, Self Contained, Correct Example)?
 
pinky deshmukh
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My code is as below :-

i have 2 combos, depending upon the selection in combo i have to populate the details on div tag.



Because when this update is done i have to again submit my form as well.

Please suggest some method thru which i can generate above html and submit the form. or correct me if i am following wrong path.

Thanks

 
Joe Ess
Bartender
Posts: 9588
13
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where's your DIV with the id "resultnormal"?
Since this doesn't look like a Struts problem, I'm going to hand it over to our resident scripting experts.
 
pinky deshmukh
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Joe.

But my issue got solved. i was not able to read whole response correctly.

Thanks for all your help.
 
No one can make you feel inferior without your consent - Eleanor Roosevelt. tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!