This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Edit vs Read Only Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Edit vs Read Only " Watch "Edit vs Read Only " New topic
Author

Edit vs Read Only

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I have a page with a bunch of fields displayed. I'd like to let the user click an "edit this page" button and turn the values into inputs. Ideally all my layout stays the same so the page doesn't jump or change size when changing modes.

I first tried to use input fields all the time but make them look like normal HTML in read-only mode. I found I could style disabled inputs with no border and with transparent background so they don't look like inputs, but IE doesn't let me set the font to black. (FireFox does)

My next two thoughts are to build plain either plain text or input fields based on mode in my JSP or to build two pages that happen to look an awful lot alike. One will probably be hard to read, the other will be duplicate maintenance. Ick and ick.

Any other better ideas? Is it time to learn or write a taglib?
[ August 28, 2007: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Did you try using readOnly instead of disabled?

Eric
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
D'oh! Never heard of it before! Thanks, I'll see if this does what I need in FireFox & IE.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

One difference between disabled and readonly that you might want to keep in mind. Disabled fields are not posted with the rest of the form. It's as if they're not there.
Readonly, fields are posted with the form but the user can't change anything in them.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
That part doesn't bother me ... I'll hide the submit button when I go readonly. They are still tab stops, which is rather interesting but might be a little unusual.

It only took me the afternoon to get this working in IE and FireFox:

I still feel like a clumsy putz on client side code, but I'm having fun and getting ocasional results. My CSS classes make readonly look just like normal text and add a little padding so it doesn't jump up and down when I toggle.

I'm trying a "Joel on Software" idea he called "big ugly text boxes", switching to Courier mono-font for data entry. My eyes are not good enough to edit words like "Illinois" in verdana any more ... the Is and ls run together.
[ August 28, 2007: Message edited by: Stan James ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Edit vs Read Only
 
Similar Threads
"reset " button not working properly
querystring values and GET method
Trying to bind inputText fields from an a4j:repeat tag to java code
How to Bypass struts validation
what is better way to initialize attributes of object constructor or through method ?