Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Struts - A MVC web framework
Tomcat - JSP/Servlet container
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
JSP - A mailing list about Java Server Pages specification and reference
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
Persistent forms question

Persistent forms question

2004-03-20       - By Brad Cox

 Back
I've hit a snag in supporting persistent form defaults in
http://virtualschool.edu/jwaa and http://virtualschool.edu/ale and
hope someone here can help. Longwinded background follows;
JDOM-specifics at the end. Here's the outline of where I hit the snag:

  void rewriteRadioAndCheckboxFields(Element element)
    throws JDOMException, ValidationFault
  {
    XPath p =
XPath.newInstance(".//input[@(protected)=radio]|.//input[@(protected)=checkbox]");
    for (Iterator i = p.selectNodes(element).iterator(); i.hasNext(); )
    {
      Object o = i.next();
      Element e = (Element)o;
      String n = e.getName();
      String nameAttr = e.getAttributeValue("name");
      String checkedAttr = e.getAttributeValue("checked");
      if (nameAttr == null)
        throw new ValidationFault(n+" element requres a name attribute");
      fieldNameList.add(nameAttr);
      if (checkedAttr != null)
        continue;
      ...now what?...
    }
  }

The problem is the now what section. If this were a text or password
field, I could do
e.setAttribute("value", "$!form.getValue('foo')"/> and velocity would
splice in the value at runtime, triggered by the $! prefix. This
doesn't work with <input name="foo" type="radio"/> (or checkbox),
which maps to <input name="foo" type="radio" checked/> if foo is
non-null or minus the checked otherwise. I can't use velocity to
compute the value because this wouldn't be well-formed XML.

What I'm considering is to replace the entire element (e) with
several lines like this
  #if ($!form.getValueList('radio').contains('Yes'))
    <input name="radio" value="Yes" type="radio"
checked="checked"/>
  #else
    <input name="radio" value="Yes" type="radio"/>
  #end Yes
but that runs afoul of what I can do inside an iterator (just remove, not add).

Maybe I can rewrite the current element (e) with the long multiline
replacement shown above, passed in as a single long line of Text?
Will try that. Meanwhile, better ideas are welcome!
--
Brad J. Cox, PhD, 703 361 4751, http://virtualschool.edu
       http://virtualschool/ale Action Learning Environment
http://virtualschool.edu/mybank Digital Rights Management System
   http://virtualschool.edu/jco Java Cryptographic Objects (JCO)
  http://virtualschool.edu/jwaa Java Web Application Architecture (JWAA)
 http://virtualschool.edu/java+ Java Preprocessor (Java+)
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@(protected)
.com

©2008 junlu.com - Jax Systems, LLC, U.S.A.