This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Edit vs Read Only

 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try using readOnly instead of disabled?

Eric
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
D'oh! Never heard of it before! Thanks, I'll see if this does what I need in FireFox & IE.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic