Hi Alberto,

Thanks for pointing out the problem. This is a bug.

I have created an issue in our database:
https://www.canoo.com/jira/browse/UBA-7064

The problem occurs because ULC uses DataOutputStream.writeUTF() for
serializing Strings.

DataOutputStream.writeUTF() imposes a limit of 65K on String length.

The following snippet offers a partial solution, it will work while setting
long String on server-to-client. But if you copy/paste long String on the
client and/or add to an existing long string in textarea, it will give the
same problem when updating the server side model.

We will try and find better work around for this.

Thanks and regards,

Janak

>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] Behalf Of Alberto Nipoti
>Sent: Tuesday, September 26, 2006 12:29 PM
>To: [EMAIL PROTECTED]
>Subject: [ULC-developer] Question about textareas - ULC 5 vs ULC 6
>
>
>We notice a strange effect in our application, using ULC 6.1.0.
>If we try to set a string longer than 65535 characters into a text area,
>we get the following exception:
>
>
>com.ulcjava.base.client.ConnectorException: error while sending requests
>
>    at
>com.ulcjava.container.local.server.LocalContainerAdapter$a_.sendReq
>uests(LocalContainerAdapter$a_.java:3)
>
>    at com.ulcjava.base.client.UISession$k_.run(UISession$k_.java:107)
>
>    at java.lang.Thread.run(Thread.java:534)
>
>Caused by: java.io.UTFDataFormatException
>
>    at java.io.DataOutputStream.writeUTF(DataOutputStream.java:342)
>
>    at java.io.DataOutputStream.writeUTF(DataOutputStream.java:300)
>
>    at
>com.ulcjava.base.shared.internal.UlcDataOutputStream.writeUTF(UlcD
>taOutputStream.java:11)
>
>    at
>com.ulcjava.base.shared.internal.UlcObjectOutputStream.writeUTF(Ulc
>ObjectOutputStream.java:107)
>
>    at
>com.ulcjava.base.shared.internal.UlcObjectOutputStream.writeObject(
>UlcObjectOutputStream.java:69)
>
>    at
>com.ulcjava.base.shared.streamcoder.MapCoder.writeObject(MapCoder.java:20)
>
>    at
>com.ulcjava.base.shared.internal.UlcObjectOutputStream.writeObject(
UlcObjectOutputStream.java:140)
>
>    at
>com.ulcjava.base.shared.streamcoder.AnythingCoder.writeObject(Anyth
>ingCoder.java:3)
>
>    at
>com.ulcjava.base.shared.internal.UlcObjectOutputStream.writeObject(
UlcObjectOutputStream.java:140)
>
>    at
>com.ulcjava.base.shared.streamcoder.MapCoder.writeObject(MapCoder.java:20)
>
>    at
>com.ulcjava.base.shared.internal.UlcObjectOutputStream.writeObject(
UlcObjectOutputStream.java:140)
>
>    at
>com.ulcjava.base.shared.internal.Request.writeRequests(Request.java:11)
>
>    at
>com.ulcjava.container.local.server.LocalContainerAdapter$a_.a(Local
>ContainerAdapter$a_.java:12)
>
>    at
>com.ulcjava.container.local.server.LocalContainerAdapter$a_.sendReq
>uests(LocalContainerAdapter$a_.java:10)
>
>    at com.ulcjava.base.client.UISession$k_.run(UISession$k_.java:107)
>
>    at java.lang.Thread.run(Thread.java:534)
>
>
>The same operation worked fine with ULC 5.2.
>
>Were some restrictions introduced about text areas?
>
>Thank you,
>Alberto

----------------------------------------------------------------------------
----------------

import com.ulcjava.base.application.AbstractApplication;
import com.ulcjava.base.application.ULCBorderLayoutPane;
import com.ulcjava.base.application.ULCButton;
import com.ulcjava.base.application.ULCFrame;
import com.ulcjava.base.application.ULCScrollPane;
import com.ulcjava.base.application.ULCTextArea;
import com.ulcjava.base.application.event.ActionEvent;
import com.ulcjava.base.application.event.IActionListener;
import com.ulcjava.base.application.event.ValueChangedEvent;
import com.ulcjava.base.client.UITextArea;
import com.ulcjava.base.development.DevelopmentRunner;

public class ULCTextAreaLargeTextWorkAroundSnippet extends
AbstractApplication {
    public void start() {
        ULCFrame frame = new
ULCFrame("ULCTextAreaLargeTextWorkAroundSnippet");

        final StringBuffer buf = new StringBuffer();
        for (int i = 0; i < 66000; i++) {
            buf.append('a');
        }
        buf.append('x');


        final ULCLargeTextArea text = new ULCLargeTextArea();
        ULCButton button = new ULCButton("SetText");
        text.setLineWrap(true);
        frame.add(new ULCScrollPane(text), ULCBorderLayoutPane.CENTER);
        frame.add(button, ULCBorderLayoutPane.SOUTH);

        button.addActionListener(new IActionListener() {
            public void actionPerformed(ActionEvent event) {
                text.setText(buf.toString());
            }
        });

        frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
        frame.setSize(300, 300);
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        DevelopmentRunner.setApplicationClass(ULCTextAreaLargeTextWorkAround
Snippet.class);
        DevelopmentRunner.run();
    }

    public static class ULCLargeTextArea extends ULCTextArea {

        public void setText(String text) {
            if ((text == null && getValue() == null) || (text != null &&
text.equals(getValue()))) {
                return;
            }
            fValue = text;
            char[] chars = new char[text.length()];
            text.getChars(0, text.length(), chars, 0);
            setStateUI("charArray", chars);
            fireValueChanged(new ValueChangedEvent(this));
        }

        protected String typeString() {
            return UILargeTextArea.class.getName();
        }

    }

    public static class UILargeTextArea extends UITextArea {
        public void setCharArray(char[] chars) {
            String s = new String(chars);
            super.setText(s);
        }
    }
}

_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to