• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Spring MVC Command Beans

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Anjanaya swamy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using portlets?

Do you have



defined? Note the id must be portletMultipartResolver
 
Anjanaya swamy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Bill,

Could you please help me in solving the issue.
 
reply
    Bookmark Topic Watch Topic
  • New Topic