1. #1
    Ext GWT Premium Member dardison's Avatar
    Join Date
    Apr 2008
    Location
    Buenos Aires, Argentina
    Posts
    168
    Vote Rating
    1
    dardison is on a distinguished road

      0  

    Default Unanswered: GXT 3.0 PropertyAccess interface and iinheritance

    Unanswered: GXT 3.0 PropertyAccess interface and iinheritance


    Hi,

    Regarding PropertyAccess interface and generators for ValueProvider etc, I have a question about using this interface with DTOs that extend other DTOs.

    I have this scenario:

    Code:
    public class TypeDTO extends ModelDTO {
        
        private String abbreviation;
        private String name;
        private Integer type;
        private String status;
            .........
            // getters & setters are hide for simplicity
    }
    
    public class MessureUnitDTO extends TypeDTO {
        
        private String messureUnitCode;
    
    
        @Mapping("code")
        public String getMessureUnitCode() {
            return messureUnitCode;
        }
    
    
        public void setMessureUnitCode(String messureUnitCode) {
            this.messureUnitCode = messureUnitCode;
        }
    }
    Now in order to implement this I have defined the following interfaces:

    Code:
    public interface TypeDTOPropertyAccess<T extends TypeDTO> extends PropertyAccess<T> {
          
        ValueProvider<T, String> abbreviation();
             
        ValueProvider<T, String> name();
             
        ValueProvider<T, Integer> type();
             
        ValueProvider<T, String> status();
    
    
        @Path("abbreviation")
        LabelProvider<MessureUnitDTO> label();
    
    
    }
    
    public interface MessureUnitDTOPropertyAccess extends TypeDTOPropertyAccess<MessureUnitDTO> {
          
        ValueProvider<MessureUnitDTO, String> messureUnitCode();
        
        @Path("messureUnitCode")
        ModelKeyProvider<MessureUnitDTO> key();
             
    }
    But this implementation is not working, when I run this I received the error:

    Code:
    [ERROR] [arballonwebtest] - Errors in 'generated://F2DFE1D83DE1FAF515E70944DB03F1CD/com/arballon/web/core/shared/model/types/parties/MessureUnitDTOPropertyAccessImpl.java'
        [ERROR] [arballonwebtest] - Line 3: The type MessureUnitDTOPropertyAccessImpl must implement the inherited abstract method TypeDTOPropertyAccess<MessureUnitDTO>.name()
        [ERROR] [arballonwebtest] - Line 3: The type MessureUnitDTOPropertyAccessImpl must implement the inherited abstract method TypeDTOPropertyAccess<MessureUnitDTO>.abbreviation()
        [ERROR] [arballonwebtest] - Line 3: The type MessureUnitDTOPropertyAccessImpl must implement the inherited abstract method TypeDTOPropertyAccess<MessureUnitDTO>.label()
        [ERROR] [arballonwebtest] - Line 3: The type MessureUnitDTOPropertyAccessImpl must implement the inherited abstract method TypeDTOPropertyAccess<MessureUnitDTO>.type()
        [ERROR] [arballonwebtest] - Line 3: The type MessureUnitDTOPropertyAccessImpl must implement the inherited abstract method TypeDTOPropertyAccess<MessureUnitDTO>.status()
    Maybe I miss something but it looks like inheritance is not supported for PropertyAccess generators. I was expecting that the generator will generates the methods of the interface and the methods of the super interface but for the error I received it seems it doesn't.

    Any help will be appreciated.
    Regards.
    Daniel

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,639
    Answers
    107
    Vote Rating
    80
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    Thanks for the use case.

    In the meantime as a workaround, you don't need to write your interface quite that way. Instead of using T in your methods, use TypeDTO - all the methods will be legal for subclasses of TypeDTO.

    For now, you'll have a problem when you try to pass it into a ColumnConfig or the like, just cast to raw ValueProvider for the time being. The fix will either be to correct those generics so a raw cast is not necessary, or find a way to make generic PropertyAccess subtypes be generated correctly.

  3. #3
    Ext GWT Premium Member dardison's Avatar
    Join Date
    Apr 2008
    Location
    Buenos Aires, Argentina
    Posts
    168
    Vote Rating
    1
    dardison is on a distinguished road

      0  

    Default


    Hi Colin, thanks for your answer.
    Doing more testing on GXT 3.0 I found other errors that maybe related, not sure to this issue.

    I have this class :

    Code:
    public class OnFlyTypeComboView<T extends TypeDTO> extends ListView<T,T> {
    ....
    ....
    	public interface Bundle extends ClientBundle {
    		@Source("TypeCombo.css")
    		TypeStyle css();
    	}
    	
    	public interface TypeStyle extends CssResource {
    		String item();
    	}
    	
    	public interface OnFlyTypeTemplate<T> extends XTemplates {
    		@XTemplate("<div class='{style.item}'><h3>{model.abbreviation}</h3>model.name</div>")
    		SafeHtml render(T model, TypeStyle style);
    	}
    	
    	@Override
    	protected SafeHtml format(T model) {
    		return this.template.render(model, bundle.css());
    	}
    }
    When I run this I received the error:

    Code:
    [DEBUG] [arballonwebtest] - Rebinding com.arballon.web.core.client.field.types.OnFlyTypeComboView.OnFlyTypeTemplate
    	[DEBUG] [arballonwebtest] - Invoking generator com.sencha.gxt.core.rebind.XTemplatesGenerator
    		[DEBUG] [arballonwebtest] - Creating XTemplate method render
    			[DEBUG] [arballonwebtest] - Running class com.sencha.gxt.data.rebind.ValueProviderCreator
    				[WARN] [arballonwebtest] - Method getAbbreviation could not be found
    				[ERROR] [arballonwebtest] - No getter can be found, unable to proceed
    This happens when it builds an instance of:

    Code:
    OnFlyTypeComboView<MessureUnitDTO> view=new OnFlyTypeComboView<MessureUnitDTO>();
    I´m really concern about this, it seems that inheritance is an issue or maybe Parameters and inheritance not sure, but will be very difficult for us to use the way is working at the beta.

    Regards.
    Daniel

  4. #4
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,639
    Answers
    107
    Vote Rating
    80
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    The @XTemplate annotation cannot be used on a generic method at this time, and there is no plan to support this: what does it mean to ask for (T extends TypeDTO).abbreviation? Either you mean TypeDTO.abbreviation, in which case the generics are useless, or you mean that every single possible T has a getAbbreviation() method, but TypeDTO doesnt - and how is any real java supposed to be written that supports that?

    The only possible case I can come up with where the method itself should support generics is when you extend the template sometimes, but want a fallback as well. In that case, take the three extra lines to declare another interface:

    Code:
    // widget requires an instance of SomeTemplate
    public interface SomeTemplate<T extends SomeType>{
      SafeHtml template(T instance);
    }
    
    //default interface
    public interface DefaultTemplate extends SomeTemplate<SomeType> {
      @XTemplate("...")
      SafeHtml template(SomeType instance);
    }
    //widget code
      private SomeTemplate t = GWT.create(DefaultTemplate.class);
      //that would not be a safe cast normally, but we get away with it here because of GWT.create
    
    //overridding code
    interface NewTemplate extends SomeTemplate<SomeTypeSubClass> {
      @XTemplate{"using subclass methods")
      SafeHtml template(SomeTypeSubClass);
    }
    SomeWidget<SomeTypeSubClass> w = new SomeWidget<SomeTypeSubClass>(GWT.create(NewTemplate.class));
    If you can come up with any usecase where it makes sense to ask for T.property, we can revisit this.

  5. #5
    Ext GWT Premium Member dardison's Avatar
    Join Date
    Apr 2008
    Location
    Buenos Aires, Argentina
    Posts
    168
    Vote Rating
    1
    dardison is on a distinguished road

      0  

    Default


    Yes Colin you are right. I don't need to use the T parameter in this case.
    I can reference directlty TypeDTO class in the method of the OnFlyTypeTemplate and define this interface without any parameter, because as you mentioned I was refering to TypeDTO.abbreviation

    I change my code tested and it works fine.
    The reason I wrote it wrong was because I misunderstand the behavoir of the XTemplate interface and I had plans to subclassify, now I see that I can't.

    Thanks for your help!
    Daniel

  6. #6
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,639
    Answers
    107
    Vote Rating
    80
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    As in my example, you still can extend the template later (with a little creative casting), and even without T, you can subclass your model and pass it into the template.

  7. #7
    Ext GWT Premium Member dardison's Avatar
    Join Date
    Apr 2008
    Location
    Buenos Aires, Argentina
    Posts
    168
    Vote Rating
    1
    dardison is on a distinguished road

      0  

    Default


    It's ok I don't need it from now Colin.
    Actually I'm more concern about the first issue that the second, now that I found my mistake.

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar