-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I am using the searchbox component which allows only a label or a html component as part of its body template.
I would like to extend the "label" variant:
<searchbox model="@load(vm.users)">
<template name="model">
<label value="@init(each) @converter('user')"/>
</template>
</searchbox>
into a html component variant:
<searchbox model="@load(vm.users)">
<template name="model">
<html><![CDATA[
<i class="z-icon-user"></i> ${each}
]]>
</html>
</template>
</searchbox>
But I need to apply @converter('user')
to ${each}
.
How can I do this?
Another way:
<template name="model">
<html content="@init(each)@converter('user')"/>
</template>
In the user
converter, you convert each User object to HTML and prepended <i class="z-icon-user"></i>
the converter is a java objcet running at the server side, but you also need a client-side custom DOM element structure.
I recommend the solutions:
convert each object in vm.users
into the expected first, then you don't need to apply the converter on each ${ech}
Create a custom item render, call the converter to convert each object in the item render and produce a custom HTML snippet.
Both solutions are obviously either not what I expected or at least way too complicated. Bottomline of my question is rather: can I use converters on initial attributes like ${name} and the answer looks like: no. If only HTML component could also allow MVVM attributes like @load(name) ... :-)
holos ( 2024-04-02 03:17:01 +0800 )editAsked: 2024-03-28 21:45:51 +0800
Seen: 8 times
Last updated: Apr 02
How can I get the remote IP Address? -- SOLVED
Embed ZK widget on external page
How can I destroy the current session and get a new session in coding at the same time?
java.lang.RuntimeException: Cannot invoke "java.util.Map.size()" because "metafiles" is null
zEmbedded and org.zkoss.zul.progressbox.position not work
zk 9.6.0.2 listbox not rendering