I have the following on the JSP
<form:form method="post" action="${submit}" id="id" commandName="object">
<form:checkboxes path="ratings" items="${ratingsList}">
Here, the ratingsList is set in the Controller.
model.put("object",object);
model.put("ratingsList",ratingsList);
I see all the checkboxes on the page when it is loaded. I am able to save it too in the ratings which is a list. But, when I come back to this page, I want that the ratings that are saved in the "ratings" - list are selected on the page.
I am getting the below error.
Caused by: org.springframework.core.convert.ConversionFailedException: Unable to convert value "[0]" from type 'java.util.List' to type 'java.lang.String'; nested exception is java.lang.IllegalArgumentException:
Related
I'm having another date issue. My date was not saving so I decided to change the format but, now I'm getting an error.
Here is the error:
Compiler Error Message: CS0103: The name 'DateAdministered' does not exist in the current context
Here is my code:
<td><strong>Date Aministered:</strong><input type="date" id="date-of-screening" name="DateAdministered" value="#(DateAdministered !=null ? DateAministered.ToString("MM/dd/yyyy") : "01/01/2000")"></td>
I have checked the name of the field to make sure it matches what's in the table and it does. I'm not sure what the problem may be.
The variables used in the display part of a cshtml page have to be c# variables, not database fields. So it sounds like you might be getting your data from the database but not putting it into a variable.
Assuming you are doing something like
var myData = db.QuerySingle( someSQLstring);
Then later you can put
<td><strong>Date Administered:</strong><input type="date" id="date-of-screening" name="DateAdministered" value="#(myData.DateAdministered !=null ? myData.DateAministered.ToString("MM/dd/yyyy") : "01/01/2000")"></td>
assuming that the query is returning a field named DateAdministered.
I got Directory Name From servlet like : E://Test//Folder1. But I want to show this output value on Kendo Dropdown list. How to show Folder Name returned from servlet and I am using Kendo Dropdown List.
getServletContext().getRealPath(relativeWebPath);
1. Get the Folder Directory into JSON Format Using Java Code
1. Mapped Action Name with Class and Method on Strtus.xml
1. Same Action Name Use on JS Drop down Function URL
I am using spring mvc 3 and my controller is passing a List from the controller to the JSP:
List suitableMatches = new ArrayList();
...//Some code that adds Files to this list
model.addAttribute("lists", suitableMatches);
and in my jsp :
<tr>
<td class="readOnly">${list.name}</td>
<td class="readOnly">${idiomSearch.testCaseID}</td>
<td class="readOnly">${list.lastModified}</td>
<td class="readOnly">Download</td>
</tr>
But I am getting the error :
Error 500: org.springframework.web.util.NestedServletException: Request processing failed; nested exception is javax.el.PropertyNotFoundException: Property 'lastModified' not found on type java.io.File
Can anyone tell me please ,how is it that list.lastModified is not working?
Depending on the version of the JSP Expression Language that your web server is using you might not be able to access non-getter methods with this syntax.
${list.name} works as File has a method called getName(). However, File does not have a method called getLastModified(), the method is just called lastModified() so you have to add brackets when calling a method that is not a getter.
So the code should read ${list.lastModified()} and you will need to use at least v2.2 of the EL jar so this will need to either be included explicitly in the web application or use a servlet container that already includes this library.
A good source for the el syntax can be found in stackoverflow's el tag description
you can use a combination of JSTL and expression language for this like
<jsp:useBean id="dateValue" class="java.util.Date"/>
<jsp:setProperty name="dateValue" property="time" value="${file.lastModified()}"/>
<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss z" value="${dateValue}" />
I have jsf-seam application in which I am uploading a file using seam:fileUpload using the code below. Also, I have made a entry of multipart-filter to restrict file size to 1 MB.
<s:fileUpload id="offerImage" data="#{myBean.data}" contentType="#myBean.contentType}" fileName="#{myBean.fileName}" fileSize="#{myBean.size}" />
<web:multipart-filter create-temp-files="true"
max-request-size="1000000"
url-pattern="*.seam"/>
Everything is working fine, except when user try to upload a file greater than 1 MB, it throws a exception. I am handling this exception as well in pages.xml.
<exception class="org.jboss.seam.web.FileUploadException">
<redirect view-id="/create.xhtml">
<message severity="ERROR">Error while uploading Offer Image, due to size limitation.</message>
</redirect>
Issue here is: All other fields in create.xhtml(other than upload field) gets blank. User should not fill all the fields again, except the file upload.
Is there any way, where in I can redirect the user to same xhtml page with all the values filled by user persists when a seamFileUpload exception occurs.
Regards,
Rajat
Are you running this page with components in conversation or page scope? If there is "just" an event scoped component your backingbeans will be initialized on each request and because of that you can have empty fields on the next rendering.
Let's discuss on the following example:
<spring:bind path="user.userName">
<input type="text" name="${status.expression}" value="${status.value}"/>
<span class="fieldError">${status.errorMessage}</span>
</spring:bind>
When this view snippet gets rendered, what do ${status.expression} and ${status.value} get evaluated to? Where do these values come from?
See this link for an explanation of what the status variables mean.
status.expression: the expression that was used to retrieve the bean or property
status.value: the actual value of the bean or property (transformed using registered PropertyEditors)
status.errorMessages: an array of error messages, resulting from validation
The status object is evaluated when the binding is done.
Also have in mind that Spring 2.0 introduced new form tags, which are probable better suited for your needs.
The bind tag documentation of Spring 3.0
See Also: BindStatus