Wicket and Spring Intergation

Posted by Vinothbabu on Stack Overflow See other posts from Stack Overflow or by Vinothbabu
Published on 2010-12-28T22:44:31Z Indexed on 2010/12/29 9:54 UTC
Read the original article Hit count: 301

Filed under:
|
|

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.

  1. What should i do which can make my onSubmit method call the Spring Service?
  2. 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.

© Stack Overflow or respective owner

Related posts about java

Related posts about spring