-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Hello, I followed the example in your getting started section to create my own form. I made an event class with the following fields:
package com.wseemann.fisticuffs.models;
public class Event {
private Integer id;
private String eventName;
private Integer eventLength;
//....
I then created Event.properties:
event-id=Event ID
event-eventName=Event Name
event-eventLength=Event Length (in days)
However when I load my page the form labels are all shown as "??????". Any ideas what I'm doing wrong?
Finally, my JSP page:
<%@page contentType="text/html; charset=UTF-8" %>
<%@page pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:bundle basename="com.wseemann.fisticuffs.models.Event">
<html>
<body>
<h1>Formio Getting Started</h1>
<c:set var="fields" value="${eventForm.fields}"/>
<form action="<c:url value="/"/>" method="post">
<div>
<label><fmt:message key="${fields.eventName.labelKey}"/>
<input type="text" name="${fields.eventName.name}" value="${fields.eventName.value}"/>
</label>
</div>
<div>
<label><fmt:message key="${fields.eventLength.labelKey}"/>
<input type="text" name="${fields.eventLength.name}" value="${fields.eventLength.value}"/>
</label>
</div>
<button name="submit" type="submit">Submit</button>
</form>
</body>
</html>
</fmt:bundle>
And controller:
@WebServlet("/")
public class PersonController extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final FormMapping<Event> eventForm =
Forms.automatic(Event.class, "event").build();
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
Event event = new Event();
FormData<Event> formData = new FormData<Event>(event, ValidationResult.empty);
FormMapping<Event> filledForm = eventForm.fill(formData);
request.setAttribute("eventForm", filledForm);
request.getRequestDispatcher("/WEB-INF/jsp/index.jsp").forward(request, response);
}
}
Metadata
Metadata
Assignees
Labels
No labels