You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Mads Riise Rasmussen (JIRA)" <ji...@apache.org> on 2008/08/01 15:46:05 UTC

[jira] Created: (WW-2744) My custom type converter does not work anymore

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.


[jira] Commented: (WW-2744) My custom type converter does not work anymore

Posted by "Mads Riise Rasmussen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45159#action_45159 ] 

Mads Riise Rasmussen commented on WW-2744:
------------------------------------------

My best guess is 2.0.9 which I used before 2.0.11 ... I've tried in 2.0.12 but with no success. Anyway I found out that if changed the signatures of my converters to the ones in com.opensymphony.xwork2.util.EnumTypeConverter, it worked again. So maybe the Type conversion page in Struts 2 guide needs to be changed.

> 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
>             Fix For: 2.1.3
>
>
> 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.


[jira] Resolved: (WW-2744) My custom type converter does not work anymore

Posted by "Musachy Barroso (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2744?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Musachy Barroso resolved WW-2744.
---------------------------------

    Resolution: Cannot Reproduce

Maybe this was fix in 2.1? I can reproduce it in showcase where a custom converter is defined as:

public class EnumTypeConverter extends StrutsTypeConverter {
   public Object convertFromString(Map context, String[] values, Class toClass) {
   ....
   }
...
}

feel free to re-open with a testcase that replicates the problem.

> 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 Ladefoged
>             Fix For: 2.1.3
>
>
> 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.


[jira] Updated: (WW-2744) My custom type converter does not work anymore

Posted by "James Holmes (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2744?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Holmes updated WW-2744:
-----------------------------

    Fix Version/s: 2.1.3

What version of Struts 2 did it work with before and what version is it not working in? Have you tried using Struts 2.0.14? Does this error still occur in Struts 2.0.14?

> 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
>             Fix For: 2.1.3
>
>
> 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.