Monday, November 28, 2011

Re: a mistake when set backgroun-color value

It's not a bug. Or at least, it's not a bug in GWT. This is the way CSS works with javascript...whenever you set styles in javascript you must use camel case, and in a css file you use hyphens. GWT was trying to stop you from making a mistake by pointing out that you had a hyphen in your css which is incorrect.

It's a pain, but it's not GWT's fault.

Paul

On 28/11/11 11:41, wahaha wrote:
> yes,i fond that the DOM.setStyleAttribute() method could not realize a
> css attribute with the character "-" correctly.
> it is a bug 操
>
> On Nov 28, 4:26 pm, wahaha<il...@yahoo.com.cn> wrote:
>> i have tryed "backgroundColor",it have made a wong.
>> use the method you suggest it success.
>> why "backgroundColor" and "backgroun-color" both make a mistake?
>> is it a bug with gwt2.3?
>>
>> On Nov 28, 1:29 pm, Gal Dolber<gal.dol...@gmail.com> wrote:
>>
>>
>>
>>
>>
>>
>>
>>> try with backgroundColor, also you don't need to use static methods
>>> hp.getElement().getStyle().setBackgroundColor("red");
>>> On Mon, Nov 28, 2011 at 12:44 AM, wahaha<il...@yahoo.com.cn> wrote:
>>>> i write these code :
>>>> -------------------------------------------------------------------------------------------------------------------------------------
>>>> HorizontalPanel hp=new HorizontalPanel();
>>>> Label lbl=new Label("aaaaa");
>>>> hp.add(lbl);
>>>> hp.setWidth("300px");
>>>> hp.setHeight("300px");
>>>> DOM.setStyleAttribute(hp.getElement(), "backgroun-color",
>>>> "red");
>>>> DOM.setStyleAttribute(hp.getElement(), "border", "1px solid
>>>> red");
>>>> RootPanel.get().add(hp);
>>>> -------------------------------------------------------------------------------------------------------------------------------------
>>>> then it wongs,the developement mod console said :
>>>> java.lang.AssertionError: The style name 'background-color' should be
>>>> in camelCase format
>>>> --
>>>> You received this message because you are subscribed to the Google Groups
>>>> "Google Web Toolkit" group.
>>>> To post to this group, send email to google-web-toolkit@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> google-web-toolkit+unsubscribe@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/google-web-toolkit?hl=en.
>>> --
>>> Guit: Elegant, beautiful, modular and *production ready* gwt applications.
>>> http://code.google.com/p/guit/

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment