Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

One same jsp file shows static content first, then same content but editable

 
david arnold
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I have a jsp file which displays static content (some name and values from bean form) first,

code: <td><bean:write name="element" property="Value"/></td>

Output:  name: Jack
address: Main Street.
city: toronto
...............

There is a Edit link on the page, I want to click the Edit link and make the page reload, and make each value (like Jack, Main Street, toronto) in a text box or field which is editable. When I click Submit button, the form will be saved. Someone told me Javascript can do this, but I do not have idea how to do it with jsp/javascript. I am new on jsp and javascript, Could anyone help?

Thanks in advance!!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64972
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do it pretty easily by just displaying a new page with text fields in a form instead of the static displays. You could also do it by using JavaScript to dynamically replace the static displays with editable counterparts, but if you are new to JavaScript that's a bit advanced.
 
david arnold
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the information.

Actually the jsp file is quite complex and it use Struts, I need to go through Action to display a new page. I would like to use Javascript to dynamiclly replace the static displays with editable counterparts, it is quite advanced for me, if there is any sample code that I could reference, that will be big help.

Thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64972
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Going through a Struts action is hardly complex -- it's very basic to the way that Struts and other Model 2 web apps work. If you are finding that Struts is getting in the way of what you are wanting to do, perhaps you need to re-evaluate its use.

In any case, if you want to approach this using JavaScript, that's fine. I've moved this to the JavaScript forum for any further discussion.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64972
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Asking for sample code won't get you much of anywhere. No one has time to write code for you, and if you've already searched on google, you already know what's out there.

You might want to consider using a JavaScript library that already has in-place editors built in. But even there, you need to learn at least basic JavaScript to make effective use of any library.

One of the easiest approaches may be to always display the data in a text field, just make them read-only when not in "edit mode". You can even use CSS to make them look less field-like when not editing.
 
david arnold
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see, Bear, thank you for the info and help. Appreciate!

Regards,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic