struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mads Riise Rasmussen (JIRA)" <j...@apache.org>
Subject [jira] Created: (WW-2744) My custom type converter does not work anymore
Date Fri, 01 Aug 2008 13:46:05 GMT
My custom type converter does not work anymore
----------------------------------------------

                 Key: WW-2744
                 URL: https://issues.apache.org/struts/browse/WW-2744
             Project: Struts 2
          Issue Type: Bug
    Affects Versions: 2.0.11
            Reporter: Mads Riise Rasmussen


My custom type converter does not work anymore. I can see in the log that convertFromString
i called but the setter for the corresponding bean property is never called. I have done some
different testing and simply cannot get it to work anymore.

package com.softscan.service.web.converter;

import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.apache.struts2.util.StrutsTypeConverter;

import com.opensymphony.xwork2.util.TypeConversionException;

public class Inet4AddressConverter extends StrutsTypeConverter {

	@SuppressWarnings("unused")
	private static final Logger log = Logger.getLogger(Inet4AddressConverter.class);
	
	@SuppressWarnings("unchecked")
	@Override
	public Object convertFromString(Map context, String[] values, Class toClass) throws TypeConversionException
{
		List<InetAddress> result = new ArrayList<InetAddress>();
        for (int i = 0; i < values.length; i++) {
        	try {
				log.debug("# Inet4Address: " + Inet4Address.getByName(values[i]));
        		result.add(Inet4Address.getByName(values[i]));
			} catch (UnknownHostException e) {
				throw new TypeConversionException("Unknown host");
			}
        }
        return result;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String convertToString(Map context, Object o) {
		List l = (List)o;
        String result = "<";
        for (Iterator i = l.iterator(); i.hasNext(); ) {
            result = result + "[" + i.next() + "]";
        }
        result = result + ">";
        return result;
	}
}


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message