开发者

Java EE and struts and JSP: java form population - action bean etc

HI everyone.

ISSUE-

Error populating nl.strohalm.cyclos.controls.cv.CvUploadForm@317bdd in /member/cvUpload javax.servlet.ServletException: BeanUtils.populate

I am working on a opensource wep app, and trying to teach my self some skills by adding new functionality.

Now The web app is called cyclos and uses - Java EE, Struts, Hibernate, JSP, Tiles-def (spring, MySql JavaScript) SETUP: controls, DAO's, services, entities etc.

I am trying to add new functionality such as a CV database for users to save a template and file.

My sample JSP form looks as follows:

<ssl:form method="post" action="/member/cvUpload" enctype="multipart/form-data">
<html:hidden property="id" />
<html:hidden property="owner" />
<html:hidden property="uploadDate" />

<table class="defaultTableContent" cellspacing="0" cellpadding="0">
    <tr>
        <td class="tdHeaderTable">TITLE HERE PLEASE !!!></td>

    </tr>
    <tr>
        <td colspan="2" align="left" class="tdContentTableLists">
            <table class="defaultTable">
                <tr>
                    <th class="tdHeaderContents" width="30%"> CV Upload -> needs properties copy / ref !!!</th>
                    <th class="tdHeaderContents" width="60%">&nbsp;</th>
                </tr>
                <tr>
                    <td>Notes </td>
                    <td><cyclos:richTextArea name="notes"  styleId="descriptionText"/></td>
                </tr>
                <tr>
                    <td>Address</td>
                    <td><html:text value="address" size="25" property="address" /><br>
                        <html:text value="address" size="25" property="address2" />
                        <html:text value="address" size="25" property="address3" />
                    </td>
                </tr>
                <tr>
                    <td>Phone Number</td>
                    <td><html:text value="0791 000 000" size="15" property="phoneNumber"/></td>
                </tr>
                <tr>
                    <td>Field of interest / industry</td>
                    <td><c:forEach var="industry" items="${industries}">
                            <label>
                                <html:radio property="industry" value="${industry}" styleClass="radio" /><bean:message key="cv.industries.${industry}" />
                            </label>
                            </c:forEach>
                    </td>
                </tr>
                <tr>
                    <td>CV upload</td>
                    <td><html:file property="cvContent" /></td>
                </tr>
                <tr>
                    <td>
                        <input type="submit" id="saveButton"  value="<bean:message key="global.submit"/>" align="center">
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>

And my java form populated by struts or how ever looks as follows:

public class CvUploadForm extends BaseBindingForm {

private Long                id;
@IndexedEmbedded(depth = 4)
private Member              owner;
// private Calendar                       creationDate;
// private Member                         memberId;
private FormFile                cvContent;
private Calendar            uploadDate;
private long                memberId;

public CvUploadForm() {
}

public CvUploadForm(Long id, Member owner, FormFile cvContent, Calendar uploadDate) {
    this.id = id;
    this.owner = owner;
    this.cvContent = cvContent;
    this.uploadDate = uploadDate;

}

public Map<String, Object> getCv() {
    return values;
}
public void setCv(final Map<String, Object> map) {
    values = map;
}

public void setCv(final String key, final Object value) {
    values.put(key, value);
}

// ++ GETTERS AND SETTERS ++

// =============================================

Now I can display my template, but my submit wont work -> and i would like to understand the issue / error shown im my output window !! (see at top and following error )

the next error shown is as follows :

Caused by: java.开发者_开发百科lang.IllegalArgumentException: Cannot invoke nl.strohalm.cyclos.controls.cv.CvUploadForm.setOwner - argument type mismatch

Plus couple more errors. (owner ov cv refers to different member table as ID - uses java enum - relationships... fetch

I am very grateful for any reply ! And mybe some clarification about the setup. I thought I onlu use the form to display bits on JSP, and the use the CV.java entity file for the maaping etc . . so I am a little lost on getting all files and the connection right as wel las understanding the error here

Thanks for any reply, if you need additional info pls let me know. Alex


You have to see what is the type of object it attempts to pass to the setOwner method. It is not an object of type Member.

Use your debugger and try to see what is trying to pass.


you should precise if it's Struts 1 or struts 2. struts 1 maps proprities to actionForm ,if it's the case you should use primitive types in form action ( not objects like member) . Struts 2 uses OGNL to map complex object to their specific bean.

this my first post on stack over flow , i hope that it khelps you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜