Wednesday, July 24, 2013

Re: HtmlPanel, custom tag and binder

I think you just can't do such a thing (using 'tr' as the tag)

The problem is that when parsing <tr><td><span id='gwt-uid-67-></span></td></tr> as innerHTML, the <tr> and <td> and simply dropped, so the HTMLPanel's root element actually becaomes the <span id='gwt-uid-67'>.

Try it for yourself: http://jsfiddle.net/7FhnW/

Maybe the IE-specific workaround is no longer needed and we could now createElement("tr").setInnerHTML("<td><span id='gwt-uid-67'></span></td>") which would work (at least in Chrome, haven't tested anywhere else).
"The innerHTML property is read-only on the colcolGroupframeSethtmlheadstyletabletBodytFoot,tHeadtitle, and tr objects."
Or maybe the IE-specific code could be pushed behind deferred binding.

Anyway, I think it's unsafe to use any table element as HTMLPanel's tag. Maybe we should just call it out in the doc…

On Tuesday, July 23, 2013 4:56:29 PM UTC+2, David Ignjić wrote:
Hello,

I have problem with widget:
Ui binder file:

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:t="urn:import:com.umantis.talent.client.thirdappraisal.widget">
<g:HTMLPanel tag="tr">
<td><g:Label ui:field="label"></g:Label></td>
<td><g:Label ui:field="period"></g:Label></td>
<td><g:Label ui:field="description"></g:Label></td>
<td><t:ValueRadioList ui:field="givenAnswer"></t:ValueRadioList></td>
<td><g:DoubleBox ui:field="scoreValue"></g:DoubleBox></td>
<td><g:TextArea ui:field="givenComment"></g:TextArea></td>
</g:HTMLPanel>
</ui:UiBinder> 


Java file:
package com.umantis.talent.client.thirdappraisal;

import java.util.Map;
import com.google.gwt.core.client.GWT;
import com.google.gwt.editor.client.Editor;
import com.google.gwt.text.shared.AbstractRenderer;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DoubleBox;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.Widget;
import com.umantis.talent.client.thirdappraisal.widget.ValueRadioList;
import com.umantis.talent.shared.dto.thirdpartyappraisal.ThirdPartyAppraisalQuestionEvaluationModel;


public class QuestionEvaluationEditor extends Composite implements Editor<ThirdPartyAppraisalQuestionEvaluationModel> {

    private static QuestionEvaluationEditorUiBinder uiBinder = GWT.create(QuestionEvaluationEditorUiBinder.class);

    interface QuestionEvaluationEditorUiBinder extends UiBinder<Widget, QuestionEvaluationEditor> {
    }

    @UiField
    Label label;

    @UiField
    Label period;

    @UiField
    Label description;

    @UiField(provided = true)
    ValueRadioList<Long> givenAnswer;

    @UiField
    DoubleBox scoreValue;

    @UiField
    TextArea givenComment;


    private Map<Long, String> dynamicListAnswers;

    public QuestionEvaluationEditor() {
        givenAnswer = new ValueRadioList<Long>(new AbstractRenderer<Long>() {

            @Override
            public String render(Long object) {
                return dynamicListAnswers.get(object);
            }
        });

        initWidget(uiBinder.createAndBindUi(this));
    }

    public void setDynamicListAnswers(Map<Long, String> dynamicListAnswers) {
        this.dynamicListAnswers = dynamicListAnswers;
        givenAnswer.setAcceptableValues(dynamicListAnswers.keySet());
    }
}


I get the error
java.lang.RuntimeException: Cannot find element with id "gwt-uid-67". Perhaps it is not attached to the document body.
at com.google.gwt.uibinder.client.LazyDomElement.get(LazyDomElement.java:70)
at com.umantis.talent.client.thirdappraisal.QuestionEvaluationEditor_QuestionEvaluationEditorUiBinderImpl$Widgets.build_f_HTMLPanel1(QuestionEvaluationEditor_QuestionEvaluationEditorUiBinderImpl.java:89)
at com.umantis.talent.client.thirdappraisal.QuestionEvaluationEditor_QuestionEvaluationEditorUiBinderImpl$Widgets.get_f_HTMLPanel1(QuestionEvaluationEditor_QuestionEvaluationEditorUiBinderImpl.java:79)
at com.umantis.talent.client.thirdappraisal.QuestionEvaluationEditor_QuestionEvaluationEditorUiBinderImpl$Widgets.access$0(QuestionEvaluationEditor_QuestionEvaluationEditorUiBinderImpl.java:78)
at com.umantis.talent.client.thirdappraisal.QuestionEvaluationEditor_QuestionEvaluationEditorUiBinderImpl.createAndBindUi(QuestionEvaluationEditor_QuestionEvaluationEditorUiBinderImpl.java:30)
at com.umantis.talent.client.thirdappraisal.QuestionEvaluationEditor_QuestionEvaluationEditorUiBinderImpl.createAndBindUi(QuestionEvaluationEditor_QuestionEvaluationEditorUiBinderImpl.java:1)
at com.umantis.talent.client.thirdappraisal.QuestionEvaluationEditor.<init>(QuestionEvaluationEditor.java:55)


But if I change line 
<g:HTMLPanel tag="tr"> to <g:HTMLPanel> all working as expected.

I looked into source and problem is with this line
    setElement(scratchDiv.getFirstChildElement());
-->this line    getElement().removeFromParent();


Ok How to solve this ?.


Thanks David Ignjic

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment