1 Reply Latest reply on Feb 14, 2007 8:23 AM by Mariusz Smykula

    SeamTest setField work diffrent than Seam.

    Mariusz Smykula Newbie

       

       protected void setField(Object object, String fieldName, Object value)
       {
       try
       {
       Field declaredField = object.getClass().getDeclaredField(fieldName);
       if ( !declaredField.isAccessible() ) declaredField.setAccessible(true);
       declaredField.set(object, value);
       }
       catch (Exception e)
       {
       throw new IllegalArgumentException("could not set field value: " + fieldName, e);
       }
       }
      


      But in Seam, there is (Iteration over class hierarchy):
       private void initMembers(Class<?> clazz, Context applicationContext)
       {
       ...
       List<Field> selectionFields = new ArrayList<Field>();
      
       for (;clazz!=Object.class; clazz = clazz.getSuperclass())
       {
      ...
      
       for (Field field: clazz.getDeclaredFields())
       {
      
      }
      }
      
      
      
      


      We have problem, because we have @In parameter in superclass. SeamTest cant setField for this parameter.

      Workaround probably is to make something like:
      setField((Superclass) bean, "x", value); ;)

      but this is very ugly