You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ben Janes <be...@se.bluewave.com> on 2003/12/16 12:31:05 UTC

RE: Problem with FormFile

No iterate loop

<%@ page    language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib  uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/meganexus.tld" prefix="mg" %>
<%@include file="sessionManager.jsp" %>
<%
    Integer curUserID=mSes.getUserId(session.getId());
    // Get Node for User
    com.meganexus.networking.map.GraphNodeContainer
gnc=com.meganexus.networking.map.GraphBuilder.getNode(curUserID.intValue());
    if (gnc.isGraphBeingRebuilt()) {
        mSes.addMessage(session.getId(),"messages.graphbeingrebuilt");
    }
    com.meganexus.networking.info.Person curUser=gnc.getNode().getPerson();

%>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html:html locale="true">
<%@include file="head.jsp" %>
<body>
    <table cellpadding="0" cellspacing="5" border="1">
        <tr>
            <td valign="top">
                <%@include file="optionsMenu.jsp" %>
            </td>
            <td valign="top">
                <%@include file="aMessage.jsp" %>
                <!-- Output information goes here -->
                <div class="clsFormContainer">
                <html:form method="POST" enctype="multipart/form-data" action="/changeContact"
focus="fname" onsubmit="return validateChangeContactForm(this);">
                    <fieldset class="clsDialogGroup">
                    <legend><bean:message key="legend.changecontact" /></legend>
                    <table cellpadding="0" cellspacing="5" >
                        <tr>
                            <td class="clsFormDataError" colspan="2">
                                <html:errors/>
                            </td>
                        </tr>
                        <tr>
                            <th class="clsFormData" colspan="6"><bean:message
key="prompt.personaldetails" /></th>
                        </tr>
                        <tr>
                            <td class="clsFormData"><bean:message key="prompt.firstname"/></td>
                            <td class="clsFormData"><html:text property="fname" size="25"
maxlength="50" value="<%= curUser.getFname() %>" /></td>
                            <td class="clsFormData" rowspan="17"><mg:showThumbnail personId="<%=
Integer.toString(curUser.getId()) %>" /></td>
                        </tr>
                        <tr>
                            <td class="clsFormData"><bean:message key="prompt.lastname"/></td>
                            <td class="clsFormData"><html:text property="lname" size="25"
maxlength="50" value="<%= curUser.getLname() %>" /></td>
                        </tr>
                        <tr>
                            <td class="clsFormData"><bean:message key="prompt.middlenames"/></td>
                            <td class="clsFormData"><html:text property="mnames" size="25"
maxlength="100" value="<%= curUser.getMnames() %>" /></td>
                        </tr>

                        <tr>
                            <td class="clsFormData"><bean:message key="prompt.DoB"/></td>
                            <td class="clsFormData">
                                <html:text property="dob" size="25" maxlength="30" value="<%=
curUser.getDoBFormatted() %>" /> <bean:message key="prompt.DoB.format"/>
                            </td>
                        </tr>
                        <tr>
                            <td class="clsFormData"><bean:message key="prompt.title"/></td>
                            <td class="clsFormData">
                                <html:select property="title" value="<%=
Short.toString(curUser.getTitleId()) %>">
                                    <html:optionsCollection name="sessionTitleList"  value="id"
label="title" />
                                </html:select>
                            </td>
                        </tr>
                        <tr>
                            <td class="clsFormData"><bean:message key="prompt.maritalstatus"/></td>
                            <td class="clsFormData">
                                <html:select property="maritalstatus" value="<%=
Byte.toString(curUser.getMaritalStatusId()) %>" >
                                    <bean:define id="tdeMStatusList" name="sessionMStatusList"
type="com.meganexus.networking.info.MaritalStatusList"  />
                                    <html:optionsCollection name="tdeMStatusList" value="id"
label="status" />
                                </html:select>
                            </td>
                        </tr>

                        <tr>
                            <th class="clsFormData" colspan="2"><bean:message
key="prompt.contactDetails" /></th>
                        </tr>
                        <tr>
                            <td class="clsFormData"><bean:message key="prompt.addrHNum"/></td>
                            <td class="clsFormData"><html:text property="addrHNum" size="25"
maxlength="150" value="<%= curUser.getAddrHNum() %>" /></td>
                        </tr>
                        <tr>
                            <td class="clsFormData"><bean:message key="prompt.addrStreet"/></td>
                            <td class="clsFormData"><html:text property="addrStreet" size="25"
maxlength="150" value="<%= curUser.getAddrStreet() %>" /></td>
                        </tr>
                        <tr>
                            <td class="clsFormData"><bean:message key="prompt.addrTown"/></td>
                            <td class="clsFormData"><html:text property="addrTown" size="25"
maxlength="150" value="<%= curUser.getAddrTown() %>" /></td>
                        </tr>
                        <tr>
                            <td class="clsFormData"><bean:message key="prompt.addrCounty"/></td>
                            <td class="clsFormData"><html:text property="addrCounty" size="25"
maxlength="150" value="<%= curUser.getAddrCounty() %>" /></td>
                        </tr>
                        <tr>
                            <td class="clsFormData"><bean:message key="prompt.addrPCode"/></td>
                            <td class="clsFormData"><html:text property="addrPCode" size="25"
maxlength="150" value="<%= curUser.getAddrPCode() %>" /></td>
                        </tr>
                        <tr>
                            <td class="clsFormData"><bean:message key="prompt.addrCountry"/></td>
                            <td class="clsFormData">
                                <html:select property="addrCountryId" value="<%=
Integer.toString(curUser.getAddrCountryId()) %>" >
                                    <html:optionsCollection name="sessionCountryList"  value="id"
label="country" />
                                </html:select>
                            </td>
                        </tr>
                        <tr>
                            <td class="clsFormData"><bean:message key="prompt.phone"/></td>
                            <td class="clsFormData"><html:text property="phone" size="25"
maxlength="150" value="<%= curUser.getPhone() %>" /></td>
                        </tr>
                        <tr>
                            <td class="clsFormData"><bean:message key="prompt.mobile"/></td>
                            <td class="clsFormData"><html:text property="mobile" size="25"
maxlength="150" value="<%= curUser.getMobile() %>" /></td>
                        </tr>
                        <tr>
                            <td class="clsFormData"><bean:message key="prompt.fax"/></td>
                            <td class="clsFormData"><html:text property="fax" size="25"
maxlength="150" value="<%= curUser.getFax() %>" /></td>
                        </tr>
                        <tr>
                            <td class="clsFormData"><bean:message key="prompt.email"/></td>
                            <td class="clsFormData"><html:text property="email" size="25"
maxlength="150" value="<%= curUser.getEmail() %>" /></td>
                        </tr>
                        <tr>
                            <td class="clsFormData"><bean:message key="prompt.notes"/></td>
                            <td class="clsFormData" colspan="2"><html:textarea property="notes"
rows="5" cols="60" value="<%= curUser.getNotes() %>" /></td>
                        </tr>
                        <tr>
                            <td class="clsFormData"><bean:message key="prompt.photo"/></td>
                            <td class="clsFormData"><html:file property="photo"
accept="image/jpeg,image/gif"/></td>
                        </tr>
                        <tr>
                            <th class="clsFormData" colspan="2">
                                <html:submit>
                                    <bean:message key="button.submit"/>
                                </html:submit>
                &#160;&#160;&#160;
                                <html:reset>
                                    <bean:message key="button.reset"/>
                                </html:reset>
                            </th>
                        </tr>
                    </table>
                </html:form>
                <html:javascript formName="changeContactForm"
                        dynamicJavascript="true"
                         staticJavascript="false"/>
                <script language="Javascript1.1" src="staticJavascript.jsp"></script>

                </div>
            </td>
        </tr>
    </table>
</body>
</html:html>

Benjamin A. Janes
------------------------------------
BLUEWAVE SVERIGE

M. +46 (0)40-631 1068
F. +46 (0)40 -631 10 50
F. +46 (0)46-540 03 50
Drottninggatan 18,
S-211 49 Malmö,
Sweden


                                                                                                                                                                                                      
                      "Aswathy  R"                                                                                                                                                                    
                      <aswathy_r@trigen        To:       "'Struts Users Mailing List'" <st...@jakarta.apache.org>                                                                               
                      t.com>                   cc:                                                                                                                                                    
                                               Subject:  RE: Problem with FormFile                                                                                                                    
                      2003-12-16 09:27                                                                                                                                                                
                      Please respond to                                                                                                                                                               
                      "Struts Users                                                                                                                                                                   
                      Mailing List"                                                                                                                                                                   
                                                                                                                                                                                                      
                                                                                                                                                                                                      




Is

<html:file property="photo"/>

within any iterate/loop ?


-----Original Message-----
From: Ben Janes [mailto:bej@se.bluewave.com]
Sent: Tuesday, December 16, 2003 1:22 PM
To: struts-user@jakarta.apache.org
Subject: Problem with FormFile



Hi

I have a problem with FormFile, in that when it has no file entered it
throws an error:

I belive this is the cause of the error:
15 Dec 2003 13:21:10 - DEBUG [Thread-2] (BeanUtils.java:873) -
setProperty(com.meganexus.networking.struts.form.ChangeContactForm@538b31,
photo, [])
15 Dec 2003 13:21:10 - DEBUG [Thread-2] (ConvertUtils.java:369) - Convert
string '' to class
'org.apache.struts.upload.FormFile'
15 Dec 2003 13:21:10 - DEBUG [Thread-2] (ConvertUtils.java:377) -   Using
converter
org.apache.commons.beanutils.converters.StringConverter@a4effe

This is the web output:
javax.servlet.ServletException: BeanUtils.populate
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254)
at
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.j
ava:821)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
...
root cause

java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.j
ava:1789)
at
org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.j
ava:1684)
at
org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:17
13)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252)
...

The ACtionForm

package...

import...

public class ChangeContactForm extends org.apache.struts.action.ActionForm {
    private FormFile photo=null;

    public FormFile getPhoto() {
        return this.photo;
    }

    public void setPhoto(Object photo) {
        System.out.println("(String)photo.class:"+photo.getClass());
        this.photo=null;
    }

    public void setPhoto(FormFile photo) {
        System.out.println("(FormFile)photo.class:"+photo.getClass());
        this.photo=photo;
    }

}

There is more code, I have just removed for sending purposes, the setPhoto
with the object parater
was to try and work round the error, though I actually believe the error is
in ConvertUtils.....
Any ideas?

Mvh
Benjamin A. Janes
------------------------------------
BLUEWAVE SVERIGE

M. +46 (0)40-631 1068
F. +46 (0)40 -631 10 50
F. +46 (0)46-540 03 50
Drottninggatan 18,
S-211 49 Malmö,
Sweden



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org







---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org