Announcement Announcement Module
No announcement yet.
binding in spring portlet MVC Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • binding in spring portlet MVC

    Hi all. I've created a portlet in my project using portlet MVC. In this portlet, I have implemented a Command object:

    public class ApplicationProjectVO implements Serializable {
    	private Application application;
    	private List<Project> projects;
    To abbreviate, I've dropped getters and setters on this post, but them exist in my code. This is my controller:

    public class ApplicationProjectManagerController {
    	private static final Logger logger = Logger
    	private ApplicationService applicationService;
    	private ProjectService projectService;
    	public void setApplicationService(ApplicationService applicationService) {
    		this.applicationService = applicationService;
    	public void setProjectService(ProjectService projectService) {
    		this.projectService = projectService;
    	@RenderMapping(params = "myaction=viewApplicationProjectForm")
    	public String doView() {
    		return "viewApplicationProjectForm";
    	@ModelAttribute(value = "applicationList")
    	public List<Application> getApplications() {
    		return applicationService.getApplications();
    	@ModelAttribute(value = "projectList")
    	public List<Project> getProjects() {
    		return projectService.getProjects();
    	public ApplicationProjectVO getCommandObject() {
    		return new ApplicationProjectVO();
    	@ActionMapping(params = "myaction=addApplicationProject")
    	public void addApplicationProject(
    			@ModelAttribute ApplicationProjectVO application,
    			BindingResult bindingResult, ActionResponse response,
    			SessionStatus sessionStatus) {
    		try {
    			if (!bindingResult.hasErrors()) {"Application = "
    						+ application.getApplication().getApplicationName());
    			} else {"A binding error happened");
    				List<ObjectError> errorList = bindingResult.getAllErrors();
    				Iterator<ObjectError> it = errorList.iterator();
    				while (it.hasNext()) {"ObjectError: " +;
    		} catch (Exception e) {
    			logger.error("ERROR: addApplicationProject method", e);
    As you can see, I've sent 2 model Objects: a List<Application> and a List<Project>, and a command object: ApplicationProjectVO.

    What I'm trying to do is showing in a table the Application list and in another table the Project list. The last column of Application list is a radio button to choose one project and bind it to ApplicationProjectVO.application:

    <portlet:actionURL var="showAddApplicationProjectActionUrl">
    	<portlet:param name="myaction" value="addApplicationProject" />
    <form:form name="appProjCatalogForm" commandName="appProj" method="post"
    	<table border="1" cellspacing="2" cellpadding="4">
    		<tr bgcolor="#99CCFF">
    			<td valign="top"><b>Id</b></td>
    			<td valign="top"><b>Name</b></td>
    			<td valign="top"><b>Version</b></td>
    			<td valign="top"><b>Path SVN</b></td>
    			<td valign="top"><b>Status</b></td>
    			<td valign="top"><b>Note</b></td>
    		<c:if test="${not empty applicationList}">
    			<c:forEach var="app" items="${applicationList}">
    					<td valign="top"><c:out value="${app.idapplication}" /></td>
    					<td valign="top"><c:out value="${app.applicationName}" /></td>
    					<td valign="top"><c:out value="${app.applicationVersion}" /></td>
    					<td valign="top"><c:out value="${app.applicationPathsvn}" /></td>
    					<td valign="top"><c:out value="${app.applicationStatus}" /></td>
    					<td valign="top"><c:out value="${app.applicationNotes}" /></td>
    					<td><form:radiobutton path="application" value="${app}" /></td>
    				<td colspan="6"></td>
    				<td><input type="submit" value="Add ApplicationProject" /></td>
    When I press Submit I get this message:

    Failed to convert property value of type 'java.lang.String' to required type 'com.oami.qaportal.domain.Application' for property 'application'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.oami.qaportal.domain.Application] for property 'application': no matching editors or conversion strategy found
    I don't understand.Take a look to my radio button code:

    <form:radiobutton path="application" value="${app}" />
    Where application is a field of type Application in my command object (ApplicationProjectVO) and ${app} is the iterating variable over the list of applications.

    What I'm doiing wrong?