File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Spring MVC Command Beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring MVC Command Beans" Watch "Spring MVC Command Beans" New topic
Author

Spring MVC Command Beans

Anjanaya swamy
Greenhorn

Joined: Jun 14, 2012
Posts: 7
hi all,

I am trying to display the values from backing bean,but getting the error as below :

org.springframework.beans.NotReadablePropertyException: Invalid property 'documentList[0].documentSelected}' of bean class [com.elm.common.domain.PartyRegnStepFour]: Bean property 'documentList[0].documentSelected}' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?


the code is as follows :

The code in jsp is as follows :

<c:forEach var="document" items="${partyRegnStepFour.documentList}" varStatus="loopStatus">
<tr>
<td>
<form:input path="documentList[${loopStatus.index}].documentId}" />
</td>
<td>
<form:input path="documentList[${loopStatus.index}].documentName}" />
</td>
<td>
<form:input path="documentList[${loopStatus.index}].mandatory}"/>
</td>
<td>
<form:input path="documentList[${loopStatus.index}].documentSelected}" type="file"/>
</td>
</tr>
</c:forEach>


The code in the bean is as follows :

public class PartyRegnStepFour implements Serializable
{
private List<DocumentUpload> documentList;
setter and getter for the list.
}

The backing bean is as follows :

public class DocumentUpload implements Serializable {
private String documentName;
private String mandatory;
private String documentId;
private CommonsMultipartFile documentSelected;

setter and getter ....
}

In controller is :

@RequestMapping(params = "renderParamRegisterNewParty=registerNewParty_Step4")
public String methodStep4(@ModelAttribute PartyRegnStepFour partyRegnStepFour, final BindingResult errors,
final ExtendedModelMap model) {

List<DocumentUpload> listFileUpload = partyRegistrationService.populateDoumentList(partyRegnStepFour, errors, portletRequest);
model.put("partyRegnStepFour", partyRegnStepFour);
return "/party/Step4";
}


Thanks in advance for the help.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1632
    
    7

Please UseCodeTags <- click

This makes snippets much easier to read and you are more likely to get a response.

Current versions of Spring enforce the limitation that the form:input tag can only represent a text input.

First of all make sure your form encoding type is set




Secondly you can try replacing the spring tag with a standard one for example



replace with


[How To Ask Questions][Read before you PM me]
Anjanaya swamy
Greenhorn

Joined: Jun 14, 2012
Posts: 7
Hi Bill,


Thanks for the response and help to solve my issue in spring.

Actually i had already placed the below line in the form tag ...

enctype="multipart/form-data


As suggested i had also updated the form tag to normal input tag as below ...

<c:forEach var="document" items="${partyRegnStepFour.documentList}" varStatus="loopStatus">
<tr>
<td>
<input name="documentList[${loopStatus.index}].documentId}" value="${document.documentId}"/>
</td>
<td>
<input name="documentList[${loopStatus.index}].documentName}" value="${document.documentName}" />
</td>
<td>
<input name="documentList[${loopStatus.index}].mandatory}" value="${document.mandatory}" />
</td>
<td>
<input name="documentList[${loopStatus.index}].documentSelected}" value="${document.documentSelected}" type="file"/>
</td>
</tr>
</c:forEach>

The values are getting displayed...but the values are not going to the action method in the controller.

In the below action method the List<DocumentUpload> is coming as NULL.

The action method in the controller is as follows :

@ActionMapping(params = "actionParamRegisterNewParty=registerNewParty_Step4")
public void actionRegisterNewParty_Step4(@ModelAttribute("partyRegnStepFour") PartyRegnStepFour partyRegnStepFour, final BindingResult errors, final ExtendedModelMap model,
final ActionRequest actionRequest, final ActionResponse actionResponse) {

List<DocumentUpload> listFileUpload = partyRegnStepFour.getDocumentList();

if (listFileUpload != null && listFileUpload.size() > 0) {
System.out.println("frm listFileUpload---------------------------------");
for (DocumentUpload doc : listFileUpload) {
System.out.println(doc.getDocumentId());
System.out.println(doc.getDocumentName());
System.out.println(doc.getMandatory());
System.out.println(doc.getDocumentSelected().getOriginalFilename());
}

} else {
System.out.println("frm else --------------------------------------------------------------------------------------------------");
}
actionResponse.setRenderParameter("renderParamRegisterNewParty", renderResponseString);
}


Advance thanks for your help.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1632
    
    7

Are you using portlets?

Do you have



defined? Note the id must be portletMultipartResolver
Anjanaya swamy
Greenhorn

Joined: Jun 14, 2012
Posts: 7
Hi Bill,

Thanks for the reply.

Yes i am using the portlet, and i am using the below in XML file.

<bean id="portletMultipartResolver"
class="org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver">
<!-- one of the properties available; the maximum file size in bytes -->
<property name="maxUploadSize" value="100000"/>
</bean>


Actually If i define the below mentioned field in partyRegnStepFour Bean ...its working fine...but if i moved to the sub bean after selecting the file ...the file name is not coming to the controller.

private CommonsMultipartFile documentSelected;
Anjanaya swamy
Greenhorn

Joined: Jun 14, 2012
Posts: 7
hi Bill,

Could you please help me in solving the issue.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring MVC Command Beans
 
Similar Threads
Binding with ArrayList in Spring
Neither BindingResult nor plain target object for bean name 'vids2m1' available as request attribute
Spring can't find bean property in a list element.
Bean property is not readable or not found.
org.springframework.beans.NotReadablePropertyException