Hi,


I found out what the problem was. I did not call setType() on the component. The problem is that I did not get a good error message but just a big stack trace on my screen (see end of this mail), so it was difficult to find this problem.

Now that I have my converter working correctly, I see that if I define a converter for a type T than my (wicket 1.2.2) converter has to deal with conversions from    T to String, String to T, and surprisingly also from T to T. So I have code like this in my conversion method:

        if (aValue == null ) {
            return null;
        }
        if ( aC.isAssignableFrom(aValue.getClass())) {
            return aValue;
        }
        if (aC.equals(String.class)) {
            return convertToString((T)aValue, getLocale());
        }
        else {
            return convertToObject((String)aValue, getLocale());
        }

Is this normal?

Cheers
  Erik

wicket.util.convert.ConversionException: Sofinummer moet precies 9 cijfers bevatten
     at nl.jmonks.bonloon.app.components.SofiNummerConverter.convertToObject(SofiNummerConverter.java:28)
     at nl.jmonks.bonloon.app.components.SofiNummerConverter.convertToObject(SofiNummerConverter.java:1)
     at nl.jmonks.wicket.components.AbstractConverter.convert(AbstractConverter.java:26)
     at wicket.util.lang.PropertyResolver$FieldGetAndSetter.setValue(PropertyResolver.java:984)
     at wicket.util.lang.PropertyResolver$ObjectAndGetSetter.setValue(PropertyResolver.java:447)
     at wicket.util.lang.PropertyResolver.setValue(PropertyResolver.java:136)
     at wicket.model.AbstractPropertyModel.onSetObject(AbstractPropertyModel.java:182)
     at wicket.model.AbstractDetachableModel.setObject(AbstractDetachableModel.java:131)
     at wicket.Component.setModelObject(Component.java:1984)
     at wicket.markup.html.form.FormComponent.updateModel(FormComponent.java:548)
     at wicket.markup.html.form.Form$11.formComponent(Form.java:917)
     at wicket.markup.html.form.Form$4.component(Form.java:459)
     at wicket.MarkupContainer.visitChildren(MarkupContainer.java:744)
     at wicket.markup.html.form.Form.visitFormComponents(Form.java:455)
     at wicket.markup.html.form.Form.updateFormComponentModels(Form.java:908)
     at wicket.markup.html.form.Form.process(Form.java:890)
     at wicket.markup.html.form.Form.onFormSubmitted(Form.java:310)
     at java.lang.reflect.Method.invoke(Method.java:585)
     at wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:163)
     at wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:74)
     at wicket.request.compound.DefaultEventProcessorStrategy.processEvents(DefaultEventProcessorStrategy.java:65)
     at wicket.request.compound.AbstractCompoundRequestCycleProcessor.processEvents(AbstractCompoundRequestCycleProcessor.java:57)
     at wicket.RequestCycle.doProcessEventsAndRespond(RequestCycle.java:852)
     at wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:885)
     at wicket.RequestCycle.step(RequestCycle.java:966)
     at wicket.RequestCycle.steps(RequestCycle.java:1040)
     at wicket.RequestCycle.request(RequestCycle.java:454)
     at wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:216)
     at wicket.protocol.http.WicketServlet.doPost(WicketServlet.java:259)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
     at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
     at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
     at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
     at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
     at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
     at java.lang.Thread.run(Thread.java:595)


Igor Vaynberg wrote:
can you show us how you use the converter?

-Igor


On 9/13/06, Erik Brakkee <[EMAIL PROTECTED]> wrote:
Igor Vaynberg wrote:
can you show us some code please?
The code is below.
The MessageValidationResult.isOk() returns false leading to a conversion exception being thrown by the converter. I can make a standalone example as well if you like.

Cheers
  Erik




package nl.jmonks.bonloon.app.components;

import java.util.Locale;

import nl.jmonks.bonloon.app.dataobjects.SofiNummerData;
import nl.jmonks.generic.validation.MessageValidationResult;
import nl.jmonks.tax.domain.SofiNummerValidator;
import nl.jmonks.wicket.components.AbstractConverter;
import wicket.WicketRuntimeException;
import wicket.util.convert.ConversionException;

public class SofiNummerConverter extends AbstractConverter<SofiNummerData> {
   
    private static final int REQUIRED_DIGIT_COUNT = 9;
   
    public SofiNummerConverter() {
        // Empty.
    }

    @Override
    public SofiNummerData convertToObject(String aValue, Locale aLocale) {
        aValue = aValue.replaceAll("\\s", "");
        aValue = aValue.replaceAll("\\.", "");
        SofiNummerValidator validator = new SofiNummerValidator();
        MessageValidationResult<String> result = validator.validate(aValue);
        if (!result.isOk()) {
            throw new ConversionException(result.getMessage());
        }
        SofiNummerData sofi =  new SofiNummerData();
        sofi.value = aValue;
        return sofi;
    }

    @Override
    public String convertToString(SofiNummerData aValue, Locale aLocale) {
        return aValue.value;
    }

}




-Igor


On 9/13/06, Erik Brakkee <[EMAIL PROTECTED]> wrote:
Hi,


When I throw a wicket.util.convert.ConversionException in my custom
IConverter, I don't see a message on the form, but instead I get to see
the stacktrace for the conversion exception on screen.

The wiki page
(http://www.wicket-wiki.org.uk/wiki/index.php/Using_custom_converters )
on custom converters says
"if conversion fails, you'll get a feedback message instead of a
stacktrace", so this seems to be an error.

This occurs in wicket 1.2.2.

Cheers
  Erik

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user




------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to