aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes One same jsp file shows static content first, then same content but editable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "One same jsp file shows static content first, then same content but editable" Watch "One same jsp file shows static content first, then same content but editable" New topic
Author

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

david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
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

Joined: Jan 10, 2002
Posts: 61424
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
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

Joined: Jan 10, 2002
Posts: 61424
    
  67

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

Joined: Jan 10, 2002
Posts: 61424
    
  67

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

Joined: Apr 10, 2009
Posts: 133
I see, Bear, thank you for the info and help. Appreciate!

Regards,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: One same jsp file shows static content first, then same content but editable