Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Problem with changing FormItemIcon.setSrc

    SmartGWT Pro 2.3
    GWT 2.0.3
    Tested with Firefox 3.6, IE7 and Chrome 6.0.472.62
    DevMode

    I have an IntegerItem that has a FormItemIcon attached to it. Depending on whether or not the field has data in it, I want to change the source of FormItemIcon (to show enable/disabled state).

    For some reason this doesn't work... here is the code:

    Code:
    HandlerRegistration rtTicketChangedReg = rtTicketNumber.addChangedHandler(new ChangedHandler(){
    
    				@Override
    				public void onChanged(ChangedEvent event) {
    					if(rtTicketNumber.getValue()!= null)
    					{
    						Log.debug("Enabling RT Ticket Icon");
    						rtTicketIcon.setSrc(GraphicalAsset.RT_ICON.getPath());
    					}
    					else
    					{
    						Log.debug("Disabling RT Ticket Icon");
    						rtTicketIcon.setSrc(GraphicalAsset.RT_ICON.getDisabled());
    					}
    					
    				}
    				
    				
    			});
    The code is executing correctly in that I can see the debug statements. But the call to rtTicketIcon.setSrc doesn't change anything visually.

    The weird this is that I'm basically doing the same thing when the record loads (in an overriden editRecord() method on the Form) and there it DOES work:

    Code:
    @Override
    		public void editRecord(Record record)
    		{
    			if(record!= null)
    			{
    
    //check whether to enable the RTTicket button
    				if(record.getAttribute(DIDOrderField.RT_TICKET_NUMBER.getName())!= null)
    				{
    					rtTicketIcon.setSrc(GraphicalAsset.RT_ICON.getPath());
    				}
    				else
    				{
    					rtTicketIcon.setSrc(GraphicalAsset.RT_ICON.getDisabled());
    				}
    }
    }

    #2
    SmartGWT Pro 2.2
    GWT 2.1.1
    Tested with Firefox 3.6
    DevMode

    Code is trying to change the image of an form item icon based on the data fetched. Its using pectin mvp framework.

    code for setting the icons initially.
    Code:
    	private FormItemIcon getLockImage() {
    		FormItemIcon icon = new FormItemIcon();
    		icon.setSrc("blank.gif");
    		return icon;
    	}
    The control does come till the setting the icons to hard or soft locks but can't see the image being changed for the icon . Checked in firebug and it still show the old icon source.


    code for setting the icons after data refresh
    Code:
    	public void setValue(Lock value) {
    			if (value == null) {
    				icon.setSrc("blank.gif");
    			} else if (value.getType() == LockType.soft) {
    				icon.setSrc("softLock.gif");
    			} else {
    				icon.setSrc("hardLock.gif");
    			}
    		}

    Comment

    Working...
    X