-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I'm trying to expand a Grid in Java but I'm being unsuccessful.
I've crated a zul template that looks like this:
<zk>
<columns>
<column hflex="min" vflex="min" label="" />
<column hflex="1" vflex="min" label="" />
</columns>
<rows>
<row>
<label id="vaccineLabel" value="" />
<textbox id="vaccineName" style="resize:none;"
readonly="true" rows="3" type="text" />
</row>
<row>
<label id="lotLabel" value="" />
<textbox id="lotValue" style="resize:none;" readonly="true"
rows="3" type="text" />
</row>
<row>
<label id="dateLabel" value="" />
<textbox id="dateValue" style="resize:none;" readonly="true"
rows="3" type="text" />
</row>
<row>
<label id="reactionsLabel" value="" />
<textbox id="reactionsText" style="resize:none;"
readonly="true" rows="3" type="text" />
</row>
<row>
<label id="observationsLabel" value="" />
<textbox id="observationsText" style="resize:none;"
readonly="true" rows="3" type="text" />
</row>
</rows>
</zk>
and my Java class looks like this:
public class ShotDescriptionGrid extends Grid implements IdSpace {
/**
*
*/
private static final long serialVersionUID = 1L;
@Wire
Label vaccineLabel;
@Wire
Textbox vaccineName;
@Wire
Label lotLabel;
@Wire
Textbox lotValue;
@Wire
Label dateLabel;
@Wire
Textbox dateValue;
@Wire
Label reactionsLabel;
@Wire
Textbox reactionsText;
@Wire
Label observationsLabel;
@Wire
Textbox observationsText;
/**
*
*/
public ShotDescriptionGrid(String vaccineLabel, String vaccineName, String lotLabel, String lotValue,
String dateLabel, String dateValue, String reactionsLabel, String reactionsText,
String observationsLabel, String observationsText) {
Executions.createComponents("/WEB-INF/grids/descriptionShots.zul", this, null);
Selectors.wireVariables(this, this, null);
Selectors.wireEventListeners(this, this);
setHeight("100%");setWidth("100%");
setStyle("overflow:auto;");
this.vaccineLabel.setValue(vaccineLabel);
this.vaccineName.setValue(vaccineName);
this.lotLabel.setValue(lotLabel);
this.lotValue.setValue(lotValue);
this.dateLabel.setValue(dateLabel);
this.dateValue.setValue(dateValue);
this.reactionsLabel.setValue(reactionsLabel);
this.reactionsText.setValue(reactionsText);
this.observationsLabel.setValue(observationsLabel);
this.observationsText.setValue(observationsText);
}
Besides the obvious extensive parameters in the constructor (this was a basic approach to see if it'd work) problem my variables aren't being wired in the component.
Am I doing something wrong or I can't extend a Grid in Java? Thanks for help.
Hello DMH,
First of all you should do the wiring of the components-variables in the @AfterCompose in order to work.
http://books.zkoss.org/wiki/ZKDeveloper'sReference/MVVM/Syntax/ViewModel/@AfterCompose
Another option would be to use a MVVM pattern which will make you life much easier:
https://www.zkoss.org/zkdemo/getting_started/mvvm
Finally as a tip i also used the zk grid component a couple of years ago but you could also use foundation or bootstrap for designing your page.
Best Regards,
Darksu
Hello DMH,
A very good article can be found at the following url:
http://blog.zkoss.org/2013/09/03/zk-7-zk-components-x-bootstrap-3/
Apart from that you can download a bootstrap theme, create a zhtml file (personal preference since it works really good), and then you can integrate zk components with MVVM.
i.e
my declaration:
<zk:zk xmlns="native" xmlns:x="xhtml" xmlns:sh="shadow" xmlns:zk="zk" xmlns:z="zul">
and a sample on how i bind a component with my controller:
<z:textbox value="@bind(vm.project.projectName)" class="form-control" width="100%" placeholder="Enter Project Name"></z:textbox>
If you need more help let me know since zk+mvvm+bootstrap can give you some impressive ui designs.
Best Regards,
Darksu
I had already seen that link. While it does seem extremely powerful it seems you have to override zk JavaScript implementation and I wonder if in that case it isn't just simpler to write your own since otherwise you'll have to learn zk implementation. Maybe for ZK 9 there'll be a more direct way.
DMH ( 2016-04-03 13:42:45 +0800 )editAsked: 2016-03-25 02:58:02 +0800
Seen: 37 times
Last updated: Apr 03 '16
why don't you just create the whole zul in Java and add eventlisteners where you need them? Much easier then what you are trying now.
chillworld ( 2016-03-25 18:18:08 +0800 )editBtw, implementatie aftercompose and out your code there. This will make already a big difference.
chillworld ( 2016-03-25 21:55:25 +0800 )edit