SimpleOutboundVariable alternative in DWR 3

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

SimpleOutboundVariable alternative in DWR 3

Sanjay Patil
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: SimpleOutboundVariable alternative in DWR 3

Mike Wilson
Administrator
I think most of your questions will be answered by looking at DWR 3's built-in EnumConverter:
 
Mike Wilson
 
Sanjay Patil wrote:

Hi all,

 

We are in the process of migrating a Spring application from DWR 2 to DWR3. Please can you advise whats the alternative for SimpleOutboundVariable

Class as its not present in DWR 3 ? We are using the LowercaseEnumConverter in DWR 2 and I would like to use it in DWR 3 too as I think we might still need it.

 

public class LowercaseEnumConverter extends BaseV20Converter implements Converter {

               

                public Object convertInbound(Class paramType, InboundVariable iv, InboundContext inctx) throws MarshallException

    {

        String value = LocalUtil.decode(iv.getValue());

 

        Object[] values;

        try

        {

            Method getter = paramType.getMethod("values", new Class[0]);

            values = (Object[]) getter.invoke(paramType, (Object[]) null);

        }

        catch (NoSuchMethodException ex)

        {

            // We would like to have done: if (!paramType.isEnum())

            // But this catch block has the same effect

            throw new MarshallException(paramType);

        }

        catch (Exception ex)

        {

            throw new MarshallException(paramType, ex);

        }

 

        for (int i = 0; i < values.length; i++)

        {

            Object en = values[i];

            if (value.equals(en.toString().toLowerCase())) // Change from standard DWR enum converter

            {

                return en;

            }

        }

 

        throw new MarshallException(paramType);

    }

 

    public OutboundVariable convertOutbound(Object object, OutboundContext outctx)

    {

        return new SimpleOutboundVariable('\'' + object.toString() + '\'', outctx, true);

    }

}

 

 

--------------------------

Sanjay Patil

Wowcher IT Team

Description: Description: Description: C:\Users\alex.adu-sarkodie\Desktop\image002.jpg

Office: 02036154459

Email: [hidden email]
Web:
www.wowcher.co.uk 

 


_____________________________________________________________________
This e-mail and any attached files are intended for the named addressee only. It contains information which may be confidential and legally privileged, and also protected by copyright. Unless you are the named addressee (or authorised to receive for the addressee) you may not copy, use or disclose it to anyone else. If you received it in error please notify the sender immediately and then delete it from your system. The views and opinions expressed in this e-mail may not reflect the views and opinions of Wowcher Limited or any of its subsidiary companies. We make every effort to keep our network free from viruses. However, you need to check this e-mail and any attachments for viruses as we take no responsibility for any virus which may be transferred by this e-mail.
Wowcher Ltd. Registered Office: Northcliffe House, 2 Derry St, Kensington, London, W8 5TT. Registered No 04264984 England.