[ 
http://issues.ops4j.org/jira/browse/QI-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_11268
 ] 

Rickard Öberg2 commented on QI-37:
----------------------------------

Hm.. to fix this it seems like the get() code would have to check if the value 
is UNSET, and if so then return "null" instead. Would that be better?

> Properties of the stateOfComposite() returned Object return String UNSET for 
> all types
> --------------------------------------------------------------------------------------
>
>                 Key: QI-37
>                 URL: http://issues.ops4j.org/jira/browse/QI-37
>             Project: Qi4j
>          Issue Type: Bug
>          Components: Core Runtime
>    Affects Versions: 0.1
>            Reporter: Sonny Gill
>            Assignee: Rickard Öberg
>
> Not sure if this can be called a bug, or if anything can be done about this..
> Calling Property.get() on the properties of the composite returned by 
> CompositeBuilder.stateOfComposite() returns the String "UNSET".
> Also Property.get().getClass() throws a ClassCastException for properties 
> that are not of type String.
> This makes it cumbersome to use the same GUI control for adding and modifying 
> objects, since the new objects require an explicit check against 
> ImmutablePropertyInstance.UNSET or literal String value "UNSET".
> TestCase -
> ______________________________________________________________________________
> import org.qi4j.bootstrap.ApplicationFactory;
> import org.qi4j.bootstrap.AssemblyException;
> import org.qi4j.bootstrap.ModuleAssembly;
> import org.qi4j.bootstrap.SingletonAssembler;
> import org.qi4j.composite.Composite;
> import org.qi4j.composite.CompositeBuilder;
> import org.qi4j.composite.CompositeBuilderFactory;
> import org.qi4j.composite.ObjectBuilderFactory;
> import org.qi4j.composite.scope.Structure;
> import org.qi4j.property.Property;
> import org.qi4j.runtime.structure.ApplicationInstance;
> public class TestCase
> {
>     public static class Main
>     {
>         @Structure
>         CompositeBuilderFactory cbf;
>         public Main() throws Exception
>         {
>             SingletonAssembler assembler = new SingletonAssembler()
>             {
>                 public void assemble( ModuleAssembly module ) throws 
> AssemblyException
>                 {
>                     module.addComposites( AComposite.class );
>                     module.addObjects( Main.class );
>                 }
>             };
>             final ApplicationInstance application = new 
> ApplicationFactory().newApplication(assembler).
>                 newApplicationInstance( "Test" );
>             application.activate();
>             ObjectBuilderFactory obf = application.getLayerInstances().get( 0 
> ).getModuleInstances().
>                 get( 0 ).getStructureContext().getObjectBuilderFactory();
>             obf.newObjectBuilder( Main.class ).injectTo( this );
>             CompositeBuilder<AComposite> builder = cbf.newCompositeBuilder( 
> AComposite.class );
>             AComposite aComposite = builder.stateOfComposite();
>             System.out.println( aComposite.propA().get() );
>             System.out.println( aComposite.propA().get().getClass() );
>         }
>         public static void main( String[] args ) throws Exception
>         {
>             new Main();
>         } 
>     }
> }
> interface A
> {
>     Property<Integer> propA();
> }
> interface AComposite extends A, Composite
> {
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.ops4j.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to