1. #1
    Sencha Premium Member Neilcoder's Avatar
    Join Date
    Apr 2011
    Location
    Ireland
    Posts
    262
    Vote Rating
    0
    Neilcoder is on a distinguished road

      0  

    Post Calling asWidget().setTitle("****")

    Calling asWidget().setTitle("****")


    I'm not sure if this is a GXT or a GWT issue, since I am using GXT components as well as GWT.

    PHP Code:
            myComboBoxExample.asWidget().setTitle("Archive Process Snapshot Report");                    
            
    String temp  myComboBoxExample.asWidget().getTitle(); 

    When I do that it doesn't set the title. I'm guessing that I don't fully understand how asWidget works right now. The GWT Api says "Widget adds support for receiving events from the browser and being added directly to panels." would I be right in thinking because setting titles is not related to " receiving events from the browser" that calling .asWidget().setTitle("****") has no affect? or is this something that occurs in GXT usage? Or is it just because I'm using comboFieldLabel as a Widget?

    In my example myComboBoxExample.asWidget() returns comboFieldLabel as a Widget. I also tried setting the title inside myComboBoxExample of comboFieldLabel and this title could be retrieved by myComboBoxExample.asWidget().getTitle() but no set using myComboBoxExample.asWidget().setTitle()

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,731
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    Javadoc for UiObject.setTitle:
    Code:
      /**
       * Sets the title associated with this object. The title is the 'tool-tip'
       * displayed to users when they hover over the object.
       * 
       * @param title the object's new title
       */
    Are you trying to set the html 'title' tooltip? In my brief testing, when setting the title of a combobox, it does indeed set a simple tooltip with that text.

    No class in GXT overrides the behavior of either Widget.asWidget or UiObject.setTitle, so asWidget should always return 'this', and setTitle should always modify the title attribute of the dom element.

    The purpose of the asWidget() method is to allow objects to implement IsWidget, so they can be added somewhere to the page, but to say no more about what they are made up of. This can be very useful in at least two ways:
    * Testing - it is possible to have presenters that only know about a View interface, and that it implements IsWidget, and to pass that in turn to a HasOneWidget or AcceptsOneWidget (like the Activities/Places api does). This allows you to easily mock those interfaces, and run tests in a normal JVM
    * Composition - instead of inheriting from some container or panel, and risking that some other user of your code rewrites the heading, or adds an additional button, you can simple implement IsWidget, and just return the actual root widget. As an example, if I am making a LoginPanel, I expect others to be able to add it to the page, to reset credentials and possibly listen for a LoginEvent or the like, but I don't expect others to add new buttons or rearrange the fields - if that is needed, then the LoginPanel class should be written for that.

  3. #3
    Sencha Premium Member Neilcoder's Avatar
    Join Date
    Apr 2011
    Location
    Ireland
    Posts
    262
    Vote Rating
    0
    Neilcoder is on a distinguished road

      0  

    Default


    Thanks for the reply.

    The way I interpret what your saying is that the widget is like a generic UI interface (sort of like component but with more going on) and I find it very useful in that respect. I agree that its useful for setting up mocks, and I've been coding in a similar way to the examples provided and most of my ui classes implement Widget and Entrypoint to make things easy to mock.

    The issue about setting the title is not a blocker for me, but going back and checking my code, I can see in this particular instance of code I cannot set the tool tip unless its done inside the asWidget method. (I can post more code if you would like to see it). In the following example I set the title inside the asWidget() method

    PHP Code:
        @Override
        
    public Widget asWidget() {

            
    FileTypeProperties props GWT.create(FileTypeProperties.class);
            
    ListStore<FileTypeFileTypes = new ListStore<FileType>(props.abbr());
            
    FileTypes.addAll(getFileTypes());

            
    ComboBox<FileTypecombo = new ComboBox<FileType>(FileTypesprops.name());
            
    addHandlersForEventObservation(comboprops.name());

            
    combo.setEmptyText("Select a FileType...");
            
    combo.setWidth(150);
            
    combo.setTypeAhead(true);
            
    combo.setTriggerAction(TriggerAction.ALL);

            
    FieldLabel comboFieldLabel = new FieldLabel(combo"Report Format");
            
    comboFieldLabel.setTitle("Archive Process Snapshot Report");

            return 
    comboFieldLabel;
        } 
    and then I call asWidget() inside another class and I set the title;

    PHP Code:
            SimpleComboBoxExample myComboBoxExample = new SimpleComboBoxExample();   
            
    myComboBoxExample.asWidget().setTitle("new title"); 
    the rollover does not change, the title is not overriden;
    Attached Images

  4. #4
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      1  

    Default


    Your asWidget methods returnes a new instance everytime it is called. This means the one you are seeing in the screen is a different one that you set the title on.

    asWidget should return the same instance, regardless how often it is called.

  5. #5
    Sencha Premium Member Neilcoder's Avatar
    Join Date
    Apr 2011
    Location
    Ireland
    Posts
    262
    Vote Rating
    0
    Neilcoder is on a distinguished road

      0  

    Default


    doh! Ahh, I think I understand what you are saying now...

    I've coded my asWidget method to return a new instance, but what I should have really done is say make comboFieldLabel a private class level field and put the following into the constructor;

    PHP Code:
    FieldLabel comboFieldLabel = new FieldLabel(combo"Report Format"); 
    so then asWidget would not create a new instance of comboFieldLabel...

  6. #6
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      1  

    Default


    If that is the only change, than your ComboBox is still always recreated. Is this really what you want?

    I would do an if check there:
    Code:
    private FieldLabel comboFieldLabel;  
      @Override
        public Widget asWidget() {
    if(this.comboFieldLabel == null) {
            FileTypeProperties props = GWT.create(FileTypeProperties.class);
            ListStore<FileType> FileTypes = new ListStore<FileType>(props.abbr());
            FileTypes.addAll(getFileTypes());
    
    
            ComboBox<FileType> combo = new ComboBox<FileType>(FileTypes, props.name());
            addHandlersForEventObservation(combo, props.name());
    
    
            combo.setEmptyText("Select a FileType...");
            combo.setWidth(150);
            combo.setTypeAhead(true);
            combo.setTriggerAction(TriggerAction.ALL);
    
    
            this.comboFieldLabel = new FieldLabel(combo, "Report Format");
    this.comboFieldLabel.setTitle("Archive Process Snapshot Report");
    }
            return this.comboFieldLabel;
        }

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi