This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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
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.
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 ]