Wicket and Spring Intergation
- by Vinothbabu
I have a wicket contact form, and i receive the form object. Now i need to pass this object to Spring Service.
package com.mysticcoders.mysticpaste.web.pages;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import com.mysticcoders.mysticpaste.model.Contact;
import org.apache.wicket.model.CompoundPropertyModel;
import com.mysticcoders.mysticpaste.services.IContact;
public class FormPage extends WebPage
{
private Contact contact;
private IContact icontact;
public FormPage()
{
// Add a FeedbackPanel for displaying our messages
FeedbackPanel feedbackPanel = new FeedbackPanel("feedback");
add(feedbackPanel);
Form<Object> form = new Form<Object>("contactForm",
new CompoundPropertyModel<Object>(contact))
{
private static final long serialVersionUID = 1L;
protected void onSubmit(Contact contact)
{
icontact.saveContact(contact);
}
};
form.add(new TextField<Object>("name"));
form.add(new TextField<Object>("email"));
form.add(new TextField<Object>("country"));
form.add(new TextField<Object>("age"));
add(form);
// add a simple text field that uses Input's 'text' property. Nothing
// can go wrong here
}
}
I am pretty much sure that we need to do something with application-context xml where i may need to wire out.
My Application-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="WicketApplication" class="com.mysticcoders.mysticpaste.web.pages.WicketApplication" />
</beans>
My Question is simple.
What should i do which can make my
onSubmit method call the Spring
Service?
Could someone let me know what needs
to modified in my
Application-context.xml so that once
the form gets submitted, it contacts
the Spring Service class.