• SqlParameter - restoreState conversion to String

    By Stefan_ Siebert 1 decade ago

    com.ibm.xsp.extlib.jdbc.model.SQLParameter.restoreState casts the _value to String.

    E.g. creating an SQLParameter of type Boolean, Double, Integer this will fail.

    If the (String) cast is removed from restoreState _value it should work correctly.

    • Workaround

      By Stefan_ Siebert 1 decade ago

      ok, this is a workaround for anyone who experiences the same bug

      import javax.faces.context.FacesContext;

      import com.ibm.xsp.extlib.jdbc.model.SqlParameter;

      //This class is a workaround for the conversion state bug reported to openntf.org on 2012/08/23
      // (see section defects on their site)

      public class SqlParameterEx extends SqlParameter{

           @Override
              public void restoreState(FacesContext context, Object value) {
                   Object[] state = (Object[]) value;
                   //Build an object with a dummy value param
                   Object[] object = new Object[]{state[0], ""};
                  super.restoreState(context, object);
                  setValue(state[1]);
              }

      }