Revision: 403
http://svn.sourceforge.net/stripes/?rev=403&view=rev
Author: tfenne
Date: 2006-09-02 10:20:27 -0700 (Sat, 02 Sep 2006)
Log Message:
-----------
Fixed for STS-263: form auto-focus can result in multiple fields with the same
HTML ID.
Modified Paths:
--------------
trunk/stripes/src/net/sourceforge/stripes/tag/InputTagSupport.java
Modified: trunk/stripes/src/net/sourceforge/stripes/tag/InputTagSupport.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/tag/InputTagSupport.java
2006-09-02 15:35:15 UTC (rev 402)
+++ trunk/stripes/src/net/sourceforge/stripes/tag/InputTagSupport.java
2006-09-02 17:20:27 UTC (rev 403)
@@ -45,6 +45,7 @@
private String formatType;
private String formatPattern;
private boolean focus;
+ private boolean syntheticId;
/** A list of the errors related to this input tag instance */
protected List<ValidationError> fieldErrors;
@@ -381,6 +382,7 @@
this.focus = focus;
if ( getId() == null ) {
+ this.syntheticId = true;
setId(String.valueOf( new Random().nextInt() ));
}
}
@@ -391,7 +393,16 @@
JspWriter out = getPageContext().getOut();
out.write("<script type=\"text/javascript\">var
z=document.getElementById('");
out.write(getId());
- out.write("'); try{z.focus(); z.select();} catch(e) {}</script>");
+ out.write("'); try{z.focus();");
+ if ("text".equals(getAttributes().get("type")) ||
"password".equals(getAttributes().get("type"))) {
+ out.write("z.select();");
+ }
+ out.write("} catch(e) {}</script>");
+
+ // Clean up tag state involved with focus
+ this.focus = false;
+ if (this.syntheticId) getAttributes().remove("id");
+ this.syntheticId = false;
}
catch (IOException ioe) {
throw new StripesJspException("Could not write javascript focus
code to jsp writer.", ioe);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development