0

Custom ListitemRenderer

asked 2006-03-28 14:05:06 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3655037

By: rfrps

IA’m trying to custom the ListitemRenderer without success.
3 28/03/2006 10:44:47 com.potix.zk.ui.sys.UiEngineImpl handleError:472
SEVERE: >>java.lang.ClassCastException: class java.lang.String cannot be converted to interface com.potix.zul.html.ListitemRenderer.
>>java.lang.InstantiationException: com.potix.zul.html.ListitemRenderer
>> at java.lang.Class.newInstance0(Unknown Source)
>> at java.lang.Class.newInstance(Unknown Source)
>> at com.potix.lang.Classes.coerce(Classes.java:1227)
>> at
>>com.potix.zk.ui.metainfo.InstanceDefinition$MemberInfo.<init>(Instance
>>Defi
nition.java:386)
>> at
>>com.potix.zk.ui.metainfo.InstanceDefinition$MemberInfo.<init>(Instance
>>Defi
nition.java:336)
>> at
>>com.potix.zk.ui.metainfo.InstanceDefinition.addMember(InstanceDefiniti
>>on.j
ava:165)
>> at com.potix.zk.ui.sys.AbstractParser.addAttribute(AbstractParser.java:365)
>> at com.potix.zk.ui.sys.AbstractParser.parse(AbstractParser.java:323)
>> at com.potix.zk.ui.sys.AbstractParser.parse(AbstractParser.java:223)
>> at com.potix.zk.ui.sys.AbstractParser.parse(AbstractParser.java:328)
>> at com.potix.zk.ui.sys.AbstractParser.parse(AbstractParser.java:198)
>> at com.potix.zk.ui.sys.AbstractParser.parse(AbstractParser.java:105)
>> at
>>com.potix.zk.ui.http.Definitions.getPageDefinitionDirectly(Definitions
>>.jav
a:89)
>> at
>>com.potix.zk.ui.http.Definitions.getPageDefinitionDirectly(Definitions
>>.jav
a:70)
>> at
>>com.potix.zk.ui.http.ServletExecution.getPageDefinitionDirectly(Servle
>>tExe
cution.java:175)
>> at
>>com.potix.zk.ui.sys.AbstractExecution.createComponentsDirectly(Abstrac
>>tExe
cution.java:193)
>> at com.potix.zk.ui.Executions.createComponentsDirectly(Executions.java:125)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>> at java.lang.reflect.Method.invoke(Unknown Source)
>> at bsh.Reflect.invokeMethod(Unknown Source)
>> at bsh.Reflect.invokeStaticMethod(Unknown Source)
>> at bsh.Name.invokeMethod(Unknown Source)
>> at bsh.BSHMethodInvocation.eval(Unknown Source)
>> at bsh.BSHPrimaryExpression.eval(Unknown Source)
>> at bsh.BSHPrimaryExpression.eval(Unknown Source)
>> at bsh.BSHBlock.evalBlock(Unknown Source)
>> at bsh.BSHBlock.eval(Unknown Source)
>> at bsh.BshMethod.invokeImpl(Unknown Source)
>> at bsh.BshMethod.invoke(Unknown Source)
>> at bsh.BshMethod.invoke(Unknown Source)
>> at bsh.Name.invokeLocalMethod(Unknown Source)
>> at bsh.Name.invokeMethod(Unknown Source)
>> at bsh.BSHMethodInvocation.eval(Unknown Source)
>> at bsh.BSHPrimaryExpression.eval(Unknown Source)
>> at bsh.BSHPrimaryExpression.eval(Unknown Source)
>> at bsh.Interpreter.eval(Unknown Source)
>> at bsh.Interpreter.eval(Unknown Source)
>> at com.potix.zk.ui.sys.PageImpl.interpret(PageImpl.java:405)
>> at
>>com.potix.zk.ui.sys.EventProcessingThread.process0(EventProcessingThre
>>ad.j
ava:370)
>> at
>>com.potix.zk.ui.sys.EventProcessingThread.run(EventProcessingThread.ja
>>va:2
85)


Look my codes:

livedata.zul
<window title="Livedata Demo" border="normal">
<label id="show"/>
<zscript>
String[] data = new String[30];
for(int j=0; j < data.length; ++j) {
data[j] = "option "+j+" ["+j+"]";
}
ListModel strset = new SimpleListModel(data);
</zscript>
<listbox id="list" width="200px" rows="10" model="${strset}"
onSelect="show.value=self.selectedItem.value;"
itemRenderer="suportsys.zul.html.ValeuListitemRenderer">
<listhead>
<listheader label="Load on Demend"/>
</listhead>
</listbox>
</window>


ValueListitemRenderer.java
// ValueListitemRenderer.java

package suportsys.zul.html;

import com.potix.zul.html.*;

public class ValueListitemRenderer implements ListitemRenderer{

public void render(Listitem item, Object data) throws Exception {
String label = data.toString();
String value = label;
int start = label.indexOf("[");
if (start>2) {
int end = label.indexOf("]");
if (end>start) {
label = label.substring(start-1);
value = label.substring(start+1,end-start-1);
}
}
item.setLabel(label);
item.setValue(value);
}
}

when data.toString() == "California [CA]", then item.setLabel("California") and item.setValue("CA")

WhatA’s wrong?

Help me, please!


delete flag offensive retag edit

4 Replies

Sort by » oldest newest

answered 2006-03-28 14:30:49 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3655193

By: tomyeh

<zscript>
renderer = new suportsys.zul.html.ValeuListitemRenderer();
</zscript>

<listbox id="list" width="200px" rows="10" model="${strset}"
onSelect="show.value=self.selectedItem.value;"
itemRenderer="${renderer}">

link publish delete flag offensive edit

answered 2006-03-28 15:41:10 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3655370

By: rfrps

I tryed this. The component rendered the 30 items but with null label and null value.

Now IA’m creating the class in ZUL document.
Look this:
<window title="Livedata Demo" border="normal">
<label id="opa"/>
<zscript>
String[] option = new String[30];
for(int j=0; j < option; ++j) {
option[j] = "option "+j+" ["+j+"]";
}
ListModel strset = new SimpleListModel(option);
ListitemRenderer myRend = new ListitemRenderer() {
public void render(Listitem item, Object data) {
String label = data.toString();
String value = label;
int start = label.indexOf("[");
if (start>2) {
int end = label.indexOf("]");
if (end>start) {
label = label.substring(start-1);
value = label.substring(start+1,end-start-1);
}
}
item.setLabel(label);
item.setValue(value);
}
};
</zscript>
<listbox id="list" width="200px" rows="10" model="${strset}"
onSelect="opa.value=self.selectedItem.value;"
itemRenderer="${myRend}" >
<listhead>
<listheader label="Load on Demend"/>
</listhead>
</listbox>
</window>

Can you help me again?

link publish delete flag offensive edit

answered 2006-03-28 16:06:38 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3655514

By: tomyeh

Your use of substring is wrong.

You might use System.out.println to debug, or compile into xxx.class then use Eclipse to debug.

link publish delete flag offensive edit

answered 2006-03-28 17:33:23 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3655824

By: rfrps

works!
Thanks very much.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2006-03-28 14:05:06 +0800

Seen: 1,005 times

Last updated: Mar 28 '06

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More