Changeset 3700

Show
Ignore:
Timestamp:
13/03/08 14:12:58 (4 years ago)
Author:
michael
Message:

Fix support for "null" values and add convience methods for next/previous URLs in lists.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/java/org/sarugo/restlet/jpa/converter/Converter.java

    r3691 r3700  
    2121    protected <T extends Object> T convertToTypeOrEntity(Class<T> type, 
    2222            String value) { 
    23         T result
     23        T result = null
    2424        try { 
    2525            result = type.cast(getApplication().getEntity(value)); 
    2626        } catch (Exception e) { 
     27            // leave as null 
     28        } 
     29        if (result == null) { 
    2730            result = convertToType(type, value); 
    2831        } 
  • trunk/src/main/java/org/sarugo/restlet/jpa/converter/FormConverter.java

    r3691 r3700  
    4141                if (value != null && p.getWriteMethod() != null) { 
    4242                    Object v = convertToTypeOrEntity(p.getPropertyType(), value); 
    43                     if (v != null) { 
     43                    if (v != null || value.equals("null")) { 
    4444                        p.getWriteMethod().invoke(entity, v); 
    4545                    } else if (p.getPropertyType().isAssignableFrom(Date.class)) { 
  • trunk/src/main/java/org/sarugo/restlet/jpa/resource/EntityList.java

    r3691 r3700  
    1111import org.restlet.data.Form; 
    1212import org.restlet.data.Parameter; 
     13import org.restlet.data.Reference; 
    1314import org.restlet.data.Request; 
    1415import org.restlet.data.Response; 
     
    155156    } 
    156157 
     158    public String getPrevUrl() { 
     159        return getRequest().getResourceRef().toString(false, false) + "?q=" 
     160                + Reference.encode(getSearchString()) + "&query=" 
     161                + Reference.encode(getQueryName()) + "&start=" + getPrevStart() 
     162                + "&max=" + getMaxResults(); 
     163    } 
     164 
     165    public String getNextUrl() { 
     166        return getRequest().getResourceRef().toString(false, false) + "?q=" 
     167                + Reference.encode(getSearchString()) + "&query=" 
     168                + Reference.encode(getQueryName()) + "&start=" + getNextStart() 
     169                + "&max=" + getMaxResults(); 
     170    } 
     171 
    157172    @Override 
    158173    public boolean allowPost() {