Yes, create a custom theme to get out of that table. css_xhtml may work immediately.

Potential issues:
- Your current approach is also going to create nodes with duplicate ids. This may confuse some browsers badly. At least remove the ID from the template - I'm not sure that order is guaranteed when you have two params with the same name at time they are submitted. Ensure you can't get a mismatch between doctype/doc name when uploading multuple files. ie. doctype[1] is associated with docname[0]. It seems vulnerable to browser-dependent processing of the form.

You may be safer generating the DOM nodes with JS programmatically rather than doing a clone. That way you'll be able to assign unique ID's for each node, add listeners for validation and use array notation in your field names to guarantee order for struts eg. "doctype[1]".

hope that helps,
Jeromy Evans

Allen, Daniel wrote:
Hi, all.

I'm working on a form that would allow some arbitrary number of
documents to be uploaded at once. The idea is that by default, one set
of document fields appears, and there's a link that a user can click to
activate some javascript that would add another set of document fields.
I have this basically working. The new fields are named the same as the
old fields, and that works just fine, with Struts automatically making
those into array properties.

My question, though, is how to make it not look horrible. I've included
the JSP below, and as you can see, I have an invisible div that I clone
and insert into the DOM tree before the Submit button. What I want is
for the cloned portion to be added as additional table rows in the table
that Struts creates for the main form. Instead, the cloned portion ends
in a table inside of a single cell in the original form's table. How can
I write the JSP so that the cloned portion fits in nicely? Is this a job
for a new theme? Have I just taken the complete wrong approach?

Thanks,
Dan Allen

__________JSP below______________

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
        
<[EMAIL PROTECTED] prefix="s" uri="/struts-tags" %>


<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
<head>
        <title>Policy Uploads</title>
        <s:head />
        <%-- The Javascript will simply multiply the HTML code generated
by Struts for us, and the identical fieldnames
             will cause Struts to see the form as working with indexed
properties. See DocumentUploadAction.java --%>
        <script language="JavaScript">
                var fileCount = 1;
                var clonedNode = null;
                var insertLoc = null;
        
                function addFileToForm() {
                        if(fileCount >= 5) {
                                alert("Please upload files in batches of
five or less, in order to maintain reasonable response times.");
                                return;
                        }
                        clonedNode =
document.getElementById('cloneTarget').cloneNode(true);
                        clonedNode.style.display = ''; // The clone
target has display "none"; drop that attribute.
                        insertLoc =
document.getElementById('documentSubmitButton');
                        insertLoc.parentNode.insertBefore(clonedNode ,
insertLoc);
                        fileCount = fileCount + 1;
                }
        </script>
</head>

<body>
        <div id="cloneTarget" style="display: none">
                <s:file name="documentFiles" label="File"/>
                <s:select name="documentTypes" label="Type"
list="documentTypeChoices"/>
                <s:textfield name="documentNames" label="Name"/> (leave
blank to copy the name from the uploaded file)
        </div>
        <s:form id="docsForm" method="POST"
action="documentUpload_execute" enctype="multipart/form-data">
                <s:textfield name="policyId" label="Upload for Policy
#"/>
                <hr/>
                <s:file name="documentFiles" label="File"/>
                <s:select name="documentTypes" label="Type"
list="documentTypeChoices"/>
                <s:textfield name="documentNames" label="Name"/> (leave
blank to copy the name from the uploaded file)
                <s:submit id="documentSubmitButton"/>
        </s:form>
        <br>
        <hr>
        <a href="javascript:addFileToForm()">Click here</a> to add more
files to the upload.
</body>
</html>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to