Hi Carsten,

>i created my own Textfield, because i want to store a complex
>object in it for putting it into a combobox, because when
>an item is selected i need additional information for processing
>the request.

It seems you are using the complex object only on the server side when a
selection is made in the combobox.

So there is no need to send the complex object to the client as part of the
TextField that is used as combobox item.

You can make use of the combobox model to store the complex object in the
following ways:

1. Hold the complex object in a custom model instead of on the text field
and access the custom model whenever you need access to the extra state.

2. You can write a custom combo box model that decorates your combo box
model. In the real combo box model you can return text fields but the
decorator combo box model translates the text field to a string.

>At runtime a exception is thrown, saying "no coder registered for
>UIMyTextfield" and hence i created one following the
>extension guide.

When selection is made in your combobox, it returns the selected item i.e. a
UITextField and sends it to the server. So you need the coder for
UITextField at the client (as param to your client side launcher e.g. jnlp)
as well as server (as param to your servlet). But the problem is that
UITextField class is not available on the server - this is a client side
class. So when you deserialize the class on the server you cannot really
create an instance of it. Therefore, sending the UITextField class to the
server from the client is not a good idea.

As I mentioned above, you should make use of the combobox model to achieve
your goal.

I hope this helps.

Thanks and regards,

Janak


>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] Behalf Of Keuch, Carsten
>Sent: Wednesday, September 27, 2006 6:27 PM
>To: [EMAIL PROTECTED] Com
>Cc: [email protected]
>Subject: AW: [ULC-developer] Problem with ULCTextField
>
>
>Dear Janak,
>
>i created my own Textfield, because i want to store a complex
>object in it for putting it into a combobox, because when
>an item is selected i need additional information for processing
>the request.
>At runtime a exception is thrown, saying "no coder registered for
>UIMyTextfield" and hence i created one following the
>extension guide. Associated classes like RegistryProvider for
>client and server were also created and arguments for jnlp
>deploying are also set. I put the classes into the corresponding
>jar files as well and added them in my jnlp file.
>Nevertheless the same exception is thrown saying "no coder
>registered for UIMyTextfield" but as i described that is not
>correct.
>Don't know if my coder is correct. The only object written on the
>OutputStream is the textfield itself by using:
>"out.writeObject(field)"
>
>The clientside textfield look pretty poor. Do i have to update the
>class with my Object. I think not, but do not know
>it...
>
>Following, the demanded "snippet":
>
>public class MISTextField extends ULCTextField {
>
>       /**
>        *
>        */
>       private static final long serialVersionUID = -5223251966405292328L;
>
>       private Object fBean = null;
>
>       private String fText = "";
>
>       public MISTextField(Object javaBean) {
>               super();
>               fBean = javaBean;
>       }
>
>       @Override
>       public void setText(String text) {
>               fText = text;
>               super.setText(text);
>       }
>
>       public Object getFBean() {
>               return fBean;
>       }
>
>       @Override
>       protected void uploadStateUI() {
>               super.uploadStateUI();
>       }
>
>       protected String typeString() {
>               return "mis.app.ulc.extension.client.UIMISTextField";
>       }
>
>       @Override
>       public String toString() {
>               return fText;
>       }
>}
>
>public class UIMISTextField extends UITextField {
>       //
>}
>
>public class MISTextFieldCoder implements IStreamCoder {
>
>       public String getPeerClassName() {
>               return UIMISTextField.class.getName();
>       }
>
>       public void writeObject(IObjectOutputStream out, Object data)
>                       throws IOException {
>               UIMISTextField field = (UIMISTextField) data;
>               out.writeObject(field);
>       }
>
>       public Object readObject(IObjectInputStream in) throws IOException {
>               return in.readObject();
>       }
>}
>
>public class MISClientTextFieldCoderRegistryProvider extends
>               DefaultClientCoderRegistryProvider {
>
>       @Override
>       protected void initializeRegistry(CoderRegistry registry) {
>               super.initializeRegistry(registry);
>               registry.registerCoder(UIMISTextField.class, new
>MISTextFieldCoder());
>       }
>}
>
>public class MISServerTextFieldRegistryProvider extends
>               DefaultServerCoderRegistryProvider {
>
>       @Override
>       protected void initializeRegistry(CoderRegistry registry) {
>               super.initializeRegistry(registry);
>               registry.registerCoder(UIMISTextField.class, new
>MISTextFieldCoder());
>       }
>}
>
>Arguments in jnlp file:
>
>               <argument>
>                       client-coder-registry-provider =
>
>mis.app.ulc.extension.coder.MISClientTextFieldCoderRegistryProvider
>               </argument>
>               <argument>
>                       server-coder-registry-provider =
>
>mis.app.ulc.extension.coder.MISServerTextFieldCoderRegistryProvider
>               </argument>
>
>Here the code where i use the textfield and put it into the combobox:
>
>       MyJavaBean next = (MyJavaBean) it.next();
>       MISTextField field = new MISTextField(next);
>       if (next.getLevel() > 1) {
>               field.setText(next.getOrgaLevel().trim() + " ("
>                       + next.getOrgaLevelShort().trim() + ")");
>               venueCombo.addItem(field);
>       }
>
>An actionListenter reacts when an item is selected as follows:
>
>       DefaultComboBoxModel list = (DefaultComboBoxModel)
>selector.getModel();
>       MyJavaBean bean = (MyJavaBean) ((MISTextField) list
>                       .getElementAt(selectedIndex)).getFBean();
>
>Hope that is all you need...
>
>Best regards,
>
>       Carsten
>
>-------------------------------------------------------------------
>-------------------------------------
>
>
>Hi Carsten,
>
>I need some more details.
>
>How have you extended ULCTextField? Are you using your custom ULCTextField
>as a renderer in a ComboBox?
>
>Can you please send a small snippet?
>
>Thanks and regards,
>
>Janak
>
>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] Behalf Of Keuch, Carsten
>Sent: Tuesday, September 26, 2006 10:58 PM
>To: Ulc-Developer (E-Mail)
>Subject: [ULC-developer] Problem with ULCTextField
>
>
>Hi all,
>
>i have a problem again...
>I derived ULCTextField and put it as an item to a ComboBox. I'm overwriting
>the two methods "setText()" and "toString()".
>When i'm trying to access this combobox item (represented as MyTextField)
>the following exception is thrown:
>
>com.ulcjava.base.shared.internal.IllegalArgumentException: No coder
>registered for class com.ulcjava.base.client.UITextField
>.....
>A listener listens to this combobox and trying to access an object
>stored in
>MyTextField...
>
>By the way. It seems not to work overwriting the
>toString()-method. There is
>only the Object-toString method called ('cause of [EMAIL PROTECTED])
>
>Can anybody held?
>
>Best regards,
>
>    Carsten
>
>_______________________________________________
>ULC-developer mailing list
>[email protected]
>http://lists.canoo.com/mailman/listinfo/ulc-developer

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

Reply via email to