[jboss-user] [JBoss Seam] - SeamTest setField work diffrent than Seam.
mariuszs
do-not-reply at jboss.com
Wed Feb 14 07:01:13 EST 2007
| 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
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016324#4016324
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016324
More information about the jboss-user
mailing list