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