Most efficient way to present collections with graph - java

I am rewriting an IBM Teamroom application with graph db. I am wondering what is most efficient to gather and display collections of vertices?
E.g. I have:
public JsonJavaArray getProfiles() {
DFramedTransactionalGraph<DGraph> graph = GraphHelper.getProfilesGraph();
Iterable<Profile> all = graph.getElements(Profile.class);
JsonJavaArray json = new JsonJavaArray();
int count = 0;
for (Profile profile : all) {
JsonJavaObject jo = new JsonJavaObject();
jo.putString("name", profile.getName());
jo.putString("department", profile.getDepartment());
jo.putString("location", profile.getLocation());
json.put(count, jo);
count++;
}
return json;
}
So I can display it on an XPage as followed in a table:
<table class="table table-sm table-inverse">
<thead>
<tr>
<th>Name</th>
<th>Department</th>
<th>Location</th>
</tr>
</thead>
<tbody>
<xp:repeat rows="30"
value="#{javascript:profiles.getProfiles();}" var="col"
indexVar="index">
<tr>
<td>
<xp:text escape="true"
value="#{col.name}">
</xp:text>
</td>
<td>
<xp:text escape="true"
value="#{col.department}">
</xp:text>
</td>
<td>
<xp:text escape="true"
value="#{col.location}">
</xp:text></td>
</tr>
</xp:repeat>
</tbody>
</table>
My profile class:
package com.wordpress.quintessens.graph.teamroom;
import org.openntf.domino.graph2.annotations.AdjacencyUnique;
import org.openntf.domino.graph2.builtin.DVertexFrame;
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.frames.Property;
import com.tinkerpop.frames.modules.typedgraph.TypeValue;
#TypeValue("profile")
public interface Profile extends DVertexFrame {
#Property("$$Key")
public String getKey();
// optional fields
#Property("Name")
public String getName();
#Property("Name")
public void setName(String n);
#Property("Department")
public String getDepartment();
#Property("Department")
public void setDepartment(String n);
#Property("Location")
public String getLocation();
#Property("Location")
public void setLocation(String n);
#Property("Email")
public String getMail();
#Property("Email")
public void setMail(String n);
// real edges!
#AdjacencyUnique(label = "hasWritten", direction = Direction.IN)
public void addTopic(Post post);
#AdjacencyUnique(label = "hasWritten", direction = Direction.IN)
public void removeTopic(Post post);
#AdjacencyUnique(label = "hasWritten", direction = Direction.IN)
public Iterable<Post> getPosts();
}
All pretty "vanilla" and it works fine. Nevertheless I am wondering if I have chosen the correct approach or have I overlooked something (read: make the architecture simpler)?

Related

How to display String of Json in jsp table

I have searched every where, but can't find the help I need.
In my servlet I receive a String containing JSON data. These data are rows from a database and contains this:
[{"note_id":1,"title":"Homework","text":"Math ex. 15, 16, 17.","color":"Yellow","datetime":""}]
My problem is that I'm not able to show these data on a html table using jstl.
This is what I get:
(I'm getting stressed and can't figure out how to solve this).
Servlet code (post method):
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
.
.
.
String output = resp.getEntity(String.class);
System.out.println("* JSON string contains: * " + output); //prints the string with json data successfully
ObjectMapper objectMapper = new ObjectMapper();
TypeReference<ArrayList<Note>> mapType = new TypeReference<ArrayList<Note>>() {};
ArrayList<Note> jsonToList = objectMapper.readValue(output, mapType);
request.setAttribute("allNotesOfUser", jsonToList);
RequestDispatcher rd = request.getRequestDispatcher("/Notes.jsp");
rd.forward(request, response);
}
jsp code (just the table part):
<table class="table table-striped">
<thead>
<tr>
<th> Id </th>
<th> Title </th>
<th> Text </th>
<th> Color </th>
<th> Date/Time </th>
</tr>
</thead>
<tbody>
<c:forEach items="${allNotesOfUser}" var="pp">
<tr>
<td><${pp.note_id}</td>
<td><${pp.title}</td>
<td><${pp.text}</td>
<td><${pp.color}</td>
<td><${pp.datetime}</td>
</tr>
</c:forEach>
</tbody>
</table>
Note entity:
#XmlRootElement
public class Note {
private int note_id;
private String title;
private String text;
private String color;
private String datetime;
public Note(int note_id, String title, String text, String color, String datetime){
this.note_id = note_id;
this.title = title;
this.text = text;
this.color = color;
this.datetime = datetime;
}
public Note(){
super();
}
public int getNote_id() {
return note_id;
}
public void setNote_id(int note_id) {
this.note_id = note_id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getDatetime() {
return datetime;
}
public void setDatetime(String datetime) {
this.datetime = datetime;
}
}
I don't know why, but I tried to insert <c:out value="" /> in my JSP code, so it looked like this:
<c:forEach items="${allNotesOfUser}" var="pp">
<tr>
<td><c:out value="${pp.note_id}" /></td>
<td><c:out value="${pp.title}" /></td>
<td><c:out value="${pp.text}" /></td>
<td><c:out value="${pp.color}" /></td>
<td><c:out value="${pp.datetime}" /></td>
</tr>
</c:forEach>
So now it's working:
Here is a link for some reference of the c:out
(Now i'll just continue and get stuck somewhere else T-T crying XD)
simple way you can send the Note entity to jsp page and print it. and you can also use JSON object bt bst way with JSON object you have to use java script. but you can also use com.google.gson.JSONObject for resolve this problem.

how to bind data to list in spring form

I have a spring form with having backing object for it. The form is like this-
<sf:form cssClass="form-horizontal" commandName="campaignModel" method="post">
<sf:input path="campaign.name" class="form-control" />
<sf:input path="landingPageModels.landingPage.url" class="form-control" />
</sf:form>
Model class(Form backing Object) -
CampaignModel.java
public class CampaignModel {
private Campaign campaign = new CampaignImpl();
private List<LandingPageModel> landingPageModels = new Arraylist<LandingPageModel>;
public Campaign getCampaign() {
return campaign;
}
public void setCampaign(Campaign campaign) {
this.campaign = campaign;
}
public List<LandingPageModel> getLandingPageModels() {
return landingPageModels;
}
public void setLandingPageModels(List<LandingPageModel> landingPageModels) {
this.landingPageModels = landingPageModels;
}
LandingPageModel.java is -
public class LandingPageModel {
private LandingPage landingPage = new LandingPageImpl();
private List<LandingPageParameterImpl> landingPageParameters = new ArrayList<LandingPageParameterImpl>();
public LandingPage getLandingPage() {
return landingPage;
}
public void setLandingPage(LandingPage landingPage) {
this.landingPage = landingPage;
}
public List<LandingPageParameterImpl> getLandingPageParameters() {
return landingPageParameters;
}
public void setLandingPageParameters(List<LandingPageParameterImpl> landingPageParameters) {
this.landingPageParameters = landingPageParameters;
}
}
LandingPage.java is -
public class LandingPageImpl extends EntityImpl implements LandingPage {
private String url;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
} }
So i want that i can insert many objects of landingPage (having their own url property) in landingPageModels list. That means i can have mulitple input tag having url property like this -
<sf:input path="landingPageModels.landingPage.url" class="form-control" />
<sf:input path="landingPageModels.landingPage.url" class="form-control" />
<sf:input path="landingPageModels.landingPage.url" class="form-control" />
But when executing this code, spring gives me error that landingPage property of landingPageModels has not getter setter method. How to solve it and how to take multiple value like this ?
In order to bind a list model property to multiple input fields, you need this in the rendered form:
<input type="text" name="landingPageModels[0].landingPage.url" class="form-control" />
<input type="text" name="landingPageModels[1].landingPage.url" class="form-control" />
<input type="text" name="landingPageModels[2].landingPage.url" class="form-control" />
Which is accomplished by:
<c:forEach items="${campaignModel.landingPageModels}" varStatus="s">
<sf:input path="landingPageModels[${s.index}].landingPage.url" class="form-control" />
</c:forEach>
The error you are getting is correct as landingPageModels is a list.
You would need to use index access like this landingPageModels[0].landingPage.url.
If you have dynamic number of input/url, then you can use <c:forEach> to create dynamic input variable names
<c:forEach items="${campaignModel.landingPageModels}" var="landingPage">
<sf:input path="landingPage.url" class="form- control" />
</c:forEach>
Will the above not works for you to view data? To get them in controller you may have to use dynamic table row concept in HTML or for each single LandingPage entry add to form bean object by clicking add button and render back.
In my case Person command object having List<Token> property, in order to bind the list of tokens we have designed page as attached screen shot below, clicking on Add button hits the controller and add the each token List<Token> and render back to same view and displays added token in list view, it facilitates to add multiple token for Person.
I dont know how to do it with spring form lib input but if you want to bind using simple html input than you can bind list like this
Simple.jsp
<%#taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%#taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%#taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
</head>
<body>
<form:form method="post" action="save.html" modelAttribute="contactForm">
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
</tr>
<tr>
<td><input name="contacts[0].firstname" /></td>
<td><input name="contacts[0].lastname" /></td>
</tr>
<tr>
<td><input name="contacts[1].firstname" /></td>
<td><input name="contacts[1].lastname" /></td>
</tr>
</table>
<br/>
<input type="submit" value="Save" />
</form:form>
</body>
</html>
#controller :
#RequestMapping(value = "/save", method = RequestMethod.POST)
public ModelAndView save(#ModelAttribute("contactForm") ContactForm contactForm) {
List<Contact> contacts = contactForm.getContacts();
if(null != contacts && contacts.size() > 0) {
ContactController.contacts = contacts;
for (Contact contact : contacts) {
System.out.printf("%s \t %s \n", contact.getFirstname(), contact.getLastname());
}
}
return new ModelAndView("show_contact", "contactForm", contactForm);
}
ContactForm.java
import java.util.List;
public class ContactForm {
private List<Contact> contacts;
public List<Contact> getContacts() {
return contacts;
}
public void setContacts(List<Contact> contacts) {
this.contacts = contacts;
}
}
Contact.java
public class Contact {
private String firstname;
private String lastname;
private String email;
private String phone;
public Contact() {
}
//getters and setters
}

Property on model attribute set in one controller method is not available in another controller method

Following contains the code inside my controller class , i am using the method public String getRegistrationForm(Map model) to return a jsp-page with a spring form on it , in this method i am setting userTab.setIsMfaEnabled(new Boolean(true)) , upon submitting the form the method :
public String registerUser(#ModelAttribute("user") UserTab user , BindingResult results , Map model)
is invoked as the handler method , but in this method the property 'isMfaEnabled' of user attribute set in the previous method is null and the line:System.out.println("user.getIsMfaEnabled() is nul"); is printing in the logs . Kindly tell me what is wrong here .
#Controller
#RequestMapping("/register")
public class RegisterUserController {
#Autowired
RegisterUserService registerUserService;
#RequestMapping(value = "/registeruser.action" , method = RequestMethod.POST)
public String registerUser(#ModelAttribute("user") UserTab user , BindingResult results , Map<String,Object> model){
System.out.println("executing regsiterUser ");
if(user == null)
System.out.println(", user is null");
if(results == null)
System.out.println("results is null");
UserTabValiator userTabValidator = new UserTabValiator();
if(user.getIsMfaEnabled() == null)
System.out.println("user.getIsMfaEnabled() is nul");
userTabValidator.validate(user, results);
if(results.hasErrors()){
return "registeruser";
}
try {
boolean val = registerUserService.isExistingUsername(user.getLoginName());
if(val){
System.out.println("username already exists");
model.put("message", "username already exists");
return "registeruser";
}
if(!val){
model.put("username", user.getLoginName());
model.put("message", "registration success ... ");
return "registrationsuccess";
}
} catch (Exception e) {
System.out.println("exception thrown");
e.printStackTrace();
return "errorpage";
}
return "errorpage";
}
#RequestMapping(value="/registeruser.view", method=RequestMethod.GET)
public String getRegistrationForm(Map<String,Object> model){
System.out.println("executing getRegistrationForm");
if(registerUserService == null)
System.out.println("register user service is null");
try{
ArrayList<MfaQuestion> allMfaQuestions = (ArrayList<MfaQuestion>) registerUserService.getAllMfaQuestions();
UserTab userTab = new UserTab();
userTab.setIsMfaEnabled(true);
model.put("user", userTab);
model.put("message", "register new user");
model.put("allMfaQuestions", allMfaQuestions);
return "registeruser";
}
catch(Exception e){
e.printStackTrace();
model.put("user", new UserTab());
model.put("message", "unable to get MFA questions");
return "registeruser";
}
}
}
UserTab Model Class :
package com.persistance.beans;
import java.util.Date;
public class UserTab {
private Integer userTabID;
private String loginName;
private String password;
private Date created;
private Date lastUpdated;
private Date lastLoginAttempt;
private Boolean isAccountLocked;
private Integer loginFailsNumber;
private Boolean isMfaEnabled;
private UserMfaMap userMfaMap;
public String toString(){
String str ="";
System.out.println("[userTabID , loginName , password");
return str;
}
public UserMfaMap getUserMfaMap() {
return userMfaMap;
}
public void setUserMfaMap(UserMfaMap userMfaMap) {
this.userMfaMap = userMfaMap;
}
public UserTab() {
super();
}
public String getLoginName() {
return loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getLastUpdated() {
return this.lastUpdated;
}
public void setLastUpdated(Date lastUpdated) {
this.lastUpdated = lastUpdated;
}
public Date getLastLoginAttempt() {
return lastLoginAttempt;
}
public void setLastLoginAttempt(Date lastLoginAttempt) {
this.lastLoginAttempt = lastLoginAttempt;
}
public Boolean getIsAccountLocked() {
return isAccountLocked;
}
public void setIsAccountLocked(Boolean isAccountLocked) {
this.isAccountLocked = isAccountLocked;
}
public Integer getLoginFailsNumber() {
return loginFailsNumber;
}
public void setLoginFailsNumber(Integer loginFailsNumber) {
this.loginFailsNumber = loginFailsNumber;
}
public Boolean getIsMfaEnabled() {
return isMfaEnabled;
}
public void setIsMfaEnabled(Boolean isMfaEnabled) {
this.isMfaEnabled = isMfaEnabled;
}
public Integer getUserTabID() {
return userTabID;
}
public void setUserTabID(Integer userTabID) {
this.userTabID = userTabID;
}
}
RegisterUser JSP page :
<form:form method="POST" action="${pageContext.request.contextPath}/register/registeruser.action" commandName ="user">
<table>
<tr>
<td><form:label path="loginName">UserName</form:label></td>
<td><form:input path="loginName" /></td>
<form:errors path="loginName" cssClass="error"/>
</tr>
<tr>
<td><form:label path="password">Password</form:label></td>
<td><form:input path="password" /></td>
<form:errors path="password" cssClass="error"/>
</tr>
<div id="question1" class="questionblock">
<tr>
<form:select path="userMfaMap.question1" >
<c:forEach items="${allMfaQuestions}" var="mfaQuestion">
<form:option value="${mfaQuestion.mfaQuestionId}">
<c:out value="${mfaQuestion.mfaQuestion}" />
</form:option>
</c:forEach>
</form:select>
</tr>
<tr>
<td><form:label path="userMfaMap.answer1">Answer:</form:label></td>
<td><form:input path="userMfaMap.answer1" /></td>
<form:errors path="userMfaMap.answer1" cssClass="error"/>
</tr>
</div>
<div id="question2" class="questionblock">
<tr>
<form:select path="userMfaMap.question2">
<c:forEach items="${allMfaQuestions}" var="mfaQuestion">
<form:option value="${mfaQuestion.mfaQuestionId}">
<c:out value="${mfaQuestion.mfaQuestion}" />
</form:option>
</c:forEach>
</form:select>
</tr>
<tr>
<td><form:label path="userMfaMap.answer2">Answer:</form:label></td>
<td><form:input path="userMfaMap.answer2" /></td>
<form:errors path="userMfaMap.answer2" cssClass="error"/>
</tr>
</div>
<div id="question3" class="questionblock">
<tr>
<form:select path="userMfaMap.question3">
<c:forEach items="${allMfaQuestions}" var="mfaQuestion">
<form:option value="${mfaQuestion.mfaQuestionId}">
<c:out value="${mfaQuestion.mfaQuestion}" />
</form:option>
</c:forEach>
</form:select>
</tr>
<tr>
<td><form:label path="userMfaMap.answer3">Answer:</form:label></td>
<td><form:input path="userMfaMap.answer3" /></td>
<form:errors path="userMfaMap.answer3" cssClass="error"/>
</tr>
</div>
<tr>
<td><input type="submit" name="submit" value="Submit"></td>
</tr>
</table>
</form:form>
Add code in the JSP form to bind the value of isMfaEnabled
<form:input path="isMfaEnabled" />

Removing dynamically added row from table having struts2

i am quite new at this and i what to know how can i get a index row from a dynamical table created with struts2. Here is what i have tried so far:
test file
<table class="table table-bordered table-striped table-condensed table-hover"
id="exp">
<thead>
<tr>
<th class="center"></th>
<th>Name</th>
</tr>
</thead>
<tbody>
<s:if test="listanume.size>0">
<s:iterator value="listanume" status="statusVar">
<tr>
<td class="center">
<button class="btn" onclick="javascript:setval(0)">
delete
</button>
</td>
<td><s:property value="nume"/></td>
</tr>
</s:iterator>
</s:if>
</tbody>
</table>
<h4>Numarul randului este: <s:property value="mysample"/> </h4>
<script>
var mysample= '';
function= setval(varval){
mysample=varval;
alert(mysample);
}
</script>
pop java
public class Pop {
private int nrrow;
private List<UserModel> listanume = new ArrayList<UserModel>();
UserModel user = new UserModel(),
user1 = new UserModel(),
user2 = new UserModel();
private String[] sample;
{
sample = new String[]{"list1", "list2", "list3"};
}
public String execute() {
user.setEmail("eret#esre");
user.setPass1("1234");
user.setNume("gigel");
user1.setEmail("yuii#ihj");
user1.setPass1("6789");
user1.setNume("marius");
user2.setEmail("nmnn#cvx");
user2.setPass1("7676");
user2.setNume("sorin");
sample1.add(user);
sample1.add(user1);
sample1.add(user2);
return "succes";
}
public String afisnrow(){
execute();
listanume=sample1;
return "succes";
}
public String[] getSample() {
return sample;
}
public void setSample(String[] sample) {
this.sample = sample;
}
public List<UserModel> getSample1() {
return sample1;
}
public void setSample1(List<UserModel> sample1) {
this.sample1 = sample1;
}
public void setNrrow(int nrrow){
this.nrrow=nrrow;
}
public int getNrrow(){
return nrrow;
}
public List<UserModel> getListanume(){
return listanume;
}
public void setListanume(List<UserModel> listanume){
this.listanume=listanume;
}
}
every row has a button on it and when i click that button i need to get the row index, i kind of stuck and run out of ideas, any suggestions?
replace
onclick="javascript:setval(0)"
with
onclick="javascript:setval(<s:property value="#statusVar.index" />)"
more info on the struts2 iterator tag here.
The solution i have found is this:
test file
<table class="table table-bordered table-striped table-condensed table-hover"
id="exp">
<thead>
<tr>
<th class="center"></th>
<th>Name</th>
</tr>
</thead>
<tbody>
<s:if test="listanume.size>0">
<s:iterator value="listanume" status="statusVar">
<tr>
<td class="center">
<button class="btn" id="<s:property value='indexrow'/>">
delete
</button>
</td>
<td><s:property value="nume"/></td>
</tr>
</s:iterator>
</s:if>
</tbody>
</table>
<i><p id="test"> No button pressed.</p></i>
<script>
$("button").click(function(e){
var idClicked = e.target.id;
$("#test").html(idClicked);
});
</script>
pop java
public class Pop {
private int indexrow;
private List<UserModel> listanume = new ArrayList<UserModel>();
UserModel user = new UserModel(),
user1 = new UserModel(),
user2 = new UserModel();
public String execute() {
user.setEmail("eret#esre");
user.setPass1("1234");
user.setNume("gigel");
user1.setEmail("yuii#ihj");
user1.setPass1("6789");
user1.setNume("marius");
user2.setEmail("nmnn#cvx");
user2.setPass1("7676");
user2.setNume("sorin");
listanume.add(user);
listanume.add(user1);
listanume.add(user2);
return "succes";
}
public String afisnrow(){
execute();
for (UserModel userModel : listanume) {
UserModel userModel1=new UserModel();
indexrow++;
userModel1.setNume(userModel.getNume());
userModel1.setIndexrow(indexrow);
listanume.add(userModel1);
}
return "succes";
}
public List<UserModel> getListanume(){
return listanume;
}
public void setListanume(List<UserModel> listanume){
this.listanume=listanume;
}
}

Create a form with multiple checkboxes in spring

I have a game and a developer. The game has a set of developers. I want to create a form where I can add a game to the database. In the form I enter the name, price and check the developers. So i create a checkbox for every developer. However when I check those the page just seems to refresh. When I debug it seems that my controller never gets to the doSubmitAction function. When I leave out the checkboxes everything works as it is supposed to.
Is spring unable to create the collection? I don't understand fully what is happening behind the scenes of Spring. This is my first project I'm creating using spring.
Here is my form:
<form:form method="POST" commandName="game" >
<table>
<tr>
<td>
Name
</td>
<td>
<form:input path="gameNaam" size="20" />
</td>
</tr>
<tr>
<td>Choose Developers</td>
<td>
<form:checkboxes id="selectdeveloper" items="${developers}" path="developers" itemLabel="naam" />
</td>
</tr>
<tr>
<td>
Price
</td>
<td>
<form:input path="prijs" size="10" />
</td>
</tr>
<tr>
<td>
<input type="submit" value="Add" />
</td>
<td></td>
</tr>
</table>
</form:form>
And the formController:
public class GameFormController extends SimpleFormController {
private GameOrganizer gameOrganizer;
public GameFormController() {
setCommandClass(Game.class);
setCommandName("game");
setFormView("AddGame");
setSuccessView("forward:/Gamedatabase.htm");
}
public void setGameOrganizer(GameOrganizer gameOrganizer){
this.gameOrganizer=gameOrganizer;
}
#Override
protected Object formBackingObject(HttpServletRequest request) throws Exception {
Game game = null;
long id = ServletRequestUtils.getLongParameter(request, "id");
if(id<=0){
game = new Game();
}else{
game = gameOrganizer.getGame(id);
}
return game;
}
#Override
protected void doSubmitAction(Object command) throws Exception {
Game game = (Game) command;
if(game.getId()<=0){
gameOrganizer.addGame(game);
}else{
gameOrganizer.update(game);
}
}
#Override
protected Map referenceData(HttpServletRequest request) throws Exception {
Set<Developer> developers = gameOrganizer.getAllDevelopers();
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("developers", developers);
return map;
}
}
Ok so apparently I had to make a propertyEditor for Developer.
There is a good explanation on this site:
http://static.springsource.org/spring/docs/2.0.x/reference/validation.html
Edit extra information:
So apparently when you check a checkbox it will give you the value as a string.
Ofcourse the Collection had to be made with developer objects.
So I created a developerEditor:
package domainmodel;
import java.beans.PropertyEditorSupport;
public class DeveloperEditor extends PropertyEditorSupport {
private GameOrganizer gameOrganizer;
public void setGameOrganizer(GameOrganizer gameOrganizer) {
this.gameOrganizer = gameOrganizer;
}
#Override
public void setAsText(String id) {
long id2 = Long.parseLong(id);
Developer type = gameOrganizer.getDeveloper(id2);
setValue(type);
}
}
And with the checkboxes I gave as itemvalue the id of the object
<form:checkboxes id="selectdeveloper" items="${allDevelopers}" itemValue="id" path="developers" itemLabel="name" />
Then in the formcontroller I override the initBinder method.
So that when I Spring has to fill in a developer object it will first convert it from string to a Developer Object using my editor.
private DeveloperEditor developerEditor;
public void setDeveloperEditor(DeveloperEditor developerEditor){
this.developerEditor = developerEditor;
developerEditor.setGameOrganizer(gameOrganizer);
}
#Override
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) {
binder.registerCustomEditor(Developer.class, developerEditor);
}
That's it folks.
If anyone has any questions I will be glad to answer them.

Categories

Resources