ZK Grid / Listbox Using List of JSONObject - json

anybody can help me using zk (zkoss) framework? I am new in this framework. I want to make a grid / listbox using list of jsonobject. I found no examples that can help me using list of jsonobject to create grid / listbox. I want to create simple listbox like this:
<?page title="Table of Users" contentType="text/html;charset=UTF-8"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<zk>
<window id="windowUsers" width="500px" apply="${userController}" viewModel="#id('vm')">
<groupbox mold="3d">
<caption label="Table of Users" />
<listbox model="#load(vm.listUser)" width="400px">
<listhead>
<listheader label="User Id"/>
<listheader label="Name"/>
<listheader label="Address"/>
<listheader label="Phone"/>
</listhead>
<template name="model" var="list">
<listitem>
<listcell label="#load(list.id)" />
<listcell label="#load(list.name)" />
<listcell label="#load(list.address)" />
<listcell label="#load(list.phone)" />
</listitem>
</template>
</listbox>
</groupbox>
</window>
thank's in advance.

ZK is typically used as serverside pages which are evaluated by java on the server. So the example above typically renders a list of java objects on the server which is output as interactive dhtml to the browser. The diagram to explain is here.
With that in mind one would not have a list of json objects on the server; you would parse them as java objects on the server and render the java objects into the page. ZK does have "client side fusion" to be able to interact with their browser side rendering engine. That however is more of an advanced feature; you should be able to write an entire system using ZK without doing any browserside programming. Here is a demo of that but I have never used myself
(warning: shameless plug) Checkout my demo app which has a simple page which renders and edits a list of objects just like your example.

thank you for the answer, it taught me enough about ZK. I've got the way to get list of JSON object shown in listbox like this:
<listitem forEach="${userController.list}">
<listcell label="${each.id}" />
<listcell label="${each.name}" />
<listcell label="${each.address}" />
<listcell label="${each.phone}" />
</listitem>

Related

SAPUI5 / CustomTile - slide by one tile

I'm developing an SAP-ui5 XML view. In that view I created dynamic custom tiles using the CustomTile tag, as demonstrated in this image:
<TileContainer
id="container"
height="400px"
tileDelete="handleTileDelete"
tiles="{/TileCollection}">
<tiles>
<CustomTile id="ct1">
<content>
<VBox>
<Toolbar class="backcolor" design="Transparent">
<Text class="sapMHeader" text="Dynamic content" />
</Toolbar>
<Button type="{infoState}" text="Button"
icon="sap-icon://approvals"
ariaDescribedBy="defaultButtonDescription genericButtonDescription">
</Button>
</VBox>
</content>
</CustomTile>
</tiles>
</TileContainer>
Currently, clicking on the navigate button slides three tiles per click. I want to get it to slide only one tile per click. How do I achieve this?
The TileContainer control is responsive meaning how many tiles you see totally depends on the available screen space and nothing else. The scroll-buttons act as an overflow and slide a complete 'page' just as a Carousel would do. There is no way of changing this behavior via existing API.
If you really want to adapt this behavior TileContainer.prototype.scrollLeft and TileContainer.prototype.scrollRight are probably a good starting point.
BR
Chris

Struts2 tags in divs appear empty

I have a s:checkbox inside a html div. When the code is run, the checkbox is outside (both) the div and the divs seem to be empty and nonexistant. Why is this occuring and how can I fix it? When I place random text inside either div, the div contains it. I set the background color to red so I can detect the div.
<div id="outer">
<div id="inner">
<s:checkbox name="chBx" id"chBx" fieldValue="false" value="true" label="Check
This" />
</div>
</div>
Like described in this answer (that you should consider upvoting too), Struts2 generates (or not) a certain kind of HTML when rendering Struts Tags, basing on the Theme you have chosen.
The default one is xhtml, that will generate a lot of stuff for you. It may be handy, but also annoying, according to how you work. Personally I prefer to generate the HTML by myself, and then I use the theme that won't generate almost any HTML: the simple Theme.
Note that when working on big projects or with multiple projects with the same, particular needs, you can also write your own custom theme (for example for generating security tokens automatically).
You can use a theme globally (in struts.xml)
<constant name="struts.ui.theme" value="simple" />
or locally to a single tag / form:
<s:checkbox name="chBx" id"chBx" fieldValue="false"
theme="simple"
value="true" label="Check This" />
In this case, you may need to write the <label> object by yourself.

Css class name getting changed in html of aspx page

I'm working on aspx pages and i have asp.net Menu and CSS assigned to it.
But when I run the application the CSS class names get changed and its dynamically created as we see in controls inside "ContentPlaceHolder".
The code is
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu"
EnableViewState="False" IncludeStyleBlock="False" Orientation="Horizontal">
<DynamicItemTemplate>
<%# Eval("Text") %>
</DynamicItemTemplate>
<Items>
.
.
.
</Items>
</asp:Menu>
please check this Image what i get when i run this..
I checked my application to know whether the Menu control is placed inside content placeholder or anything. But its not.
Do anyone know how to solve this issue.
class="menu ct100..." means that this element has two classes 1:menu and 2:ct100...
and nothing is wrong with it!the ct100... is generated by asp.net and if it is different any time you run the page it's up to asp.net component and if you dont like that try not to use this built in component, that i think you should do it.
by the way the only thing is changing when using master pages is client side id, that you can avoid this from happening by code below
<asp:TextBox ID="myId" runat="server" ClientIDMode="Static"></asp:TextBox>
set ClientIDMode to Static

How to send raw data to Printer with Java Applet

Thanks in Advance.
I am new to Java Applet, i will tell my requirement and hope will get solution.
This is my Html Coding
<html>
<head><title>Test Print Via Applet</title></head>
<body>
<div id="text_to_print">
This is my Office<br />
This is my Office Address<br />
<center>Header of the Receipt</center><br />
1. Product 1 100.00<br />
2. Product 2 200.00<br />
------<br />
TOTAL 300.00<br />
------<br />
Thanks for the Purchase.
</div>
<input type="button" value="Print Directly to the Dot Matrix by using Applet" />
</body>
</html>
Now, if anyone click the Button the contend inside the "text_to_print" div should print in the dot matrix printer directly without printer dialog.
One of my Friend told me that, this is possible if we use Applet. I search regard this on internet, but still I couldn't get the right solution for me need.
Please help me to solve the issue.
Once again thanks in advance.
https://code.google.com/p/jzebra/
Provides a a great interface to talk to the printer through javascript. Eventually the java applet does the job.

Deploying Content Type with Publishing HTML Field by Feature saving content not correctly

I have a problem using a Publishing HTML Field.
The Elements.xml:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field ID="{987B9BA2-23AB-4E52-99DD-2D59BAA79F4B}" Name="LeftContent" DisplayName="Left Content" RichText="TRUE" RichTextMode="FullHtml" Type="HTML" Hidden="FALSE"></Field>
<!-- Parent ContentType: Article Page (0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D) -->
<ContentType ID="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D002da882f450a44abaacff86118ffffaeb"
Name="Left Content"
Version="0">
<FieldRefs>
<FieldRef ID="{987B9BA2-23AB-4E52-99DD-2D59BAA79F4B}"/>
</FieldRefs>
</ContentType>
</Elements>
In my Page Layout I use ...
<PublishingWebControls:RichHtmlField id="rchHtmlFldROSTableTwoColumnRight" FieldName="ROSTableTwoColumnRight" runat="server"/>
The problem is that when I create a page based on the page layout with this content type and edit the field, SharePoint saves the content not as HTML but HTML Entities. So in not-edit-mode you see the HTML source code like Hello World
I hope somebody can help me.
Thanks!! ;)
Try this snippet
<Field ID="0000000-0000-0000-0000-000000000000"
DisplayName="Sample Rich Text Field"
Name="SampleRichTextField"
StaticName="SampleRichTextField"
Group="Sample Fields"
Type="Note"
RichText="TRUE"
RichTextMode="FullHtml"
Sealed="FALSE"
SourceID="http://schemas.microsoft.com/sharepoint/v3" />
Try using Telerik's free RadMossHTMLEditor. The OOTB publishing HTML field does not have cross-browser support. The free control from Telerik works great for me. The controls is called RadEdtior Moss Lite.
Get it from here - http://www.telerik.com/account/downloads/product-versions/single-version.aspx?pmvid=0&pid=543
Dont forget to get the documentation too.
<Field ID="{987B9BA2-23AB-4E52-99DD-2D59BAA79F4B}"
Name="LeftContent"
DisplayName="Left Content"
RichText="TRUE"
**RichTextMode="ThemeHtml"**
Type="HTML"
Hidden="FALSE">
</Field>
Thats the solution!!!! ;)