Hi Greg,
Yes.I use the example data-binding from pivot-tutorials.just change the
XML.my pivot version is 1.5.1
|--------------------------------------------------------------------------|
|package testing; |
| |
|import java.io.InputStream; |
| |
|import org.apache.pivot.beans.BeanAdapter; |
|import org.apache.pivot.collections.Map; |
|import org.apache.pivot.json.JSONSerializer; |
|import org.apache.pivot.wtk.Application; |
|import org.apache.pivot.wtk.Button; |
|import org.apache.pivot.wtk.ButtonPressListener; |
|import org.apache.pivot.wtk.DesktopApplicationContext; |
|import org.apache.pivot.wtk.Display; |
|import org.apache.pivot.wtk.Form; |
|import org.apache.pivot.wtk.Label; |
|import org.apache.pivot.wtk.PushButton; |
|import org.apache.pivot.wtk.Window; |
|import org.apache.pivot.wtkx.WTKXSerializer; |
| |
|public class DataBinding implements Application { |
| private Window window = null; |
| private Form form = null; |
| private PushButton loadJavaButton = null; |
| private PushButton loadJSONButton = null; |
| private PushButton clearButton = null; |
| private Label sourceLabel = null; |
| |
| private static final Contact CONTACT = new Contact("101", "Joe User", |
| new Address("123 Main St.", "Cambridge", "MA", "02142"), |
| "(617) 555-1234", "[email protected]", |
| new IMAccount("juser1234", "AIM")); |
| |
| @Override |
| public void startup(Display display, Map<String, String> properties) |
| throws Exception { |
| WTKXSerializer wtkxSerializer = new WTKXSerializer(); |
| window = (Window)wtkxSerializer.readObject(this, |
|"data_binding.wtkx"); |
| form = (Form)wtkxSerializer.get("form"); |
| loadJavaButton = (PushButton)wtkxSerializer.get("loadJavaButton");|
| loadJSONButton = (PushButton)wtkxSerializer.get("loadJSONButton");|
| clearButton = (PushButton)wtkxSerializer.get("clearButton"); |
| sourceLabel = (Label)wtkxSerializer.get("sourceLabel"); |
| |
| loadJavaButton.getButtonPressListeners().add(new |
|ButtonPressListener() { |
| @Override |
| public void buttonPressed(Button button) { |
| form.load(new BeanAdapter(CONTACT)); |
| sourceLabel.setText("Java"); |
| } |
| }); |
|--------------------------------------------------------------------------|
private static final Contact CONTACT = new Contact("101", "Joe User",
new Address("123 Main St.", "Cambridge", "MA", "02142"),
"(617) 555-1234", "[email protected]",
new IMAccount("juser1234", "AIM"));
Best regards,
Ken Jiang
*******************************************
Murata Electronics Trading (Shenzhen) Co.,Ltd
Tel:86-755-82847251
E-mail:[email protected]
*******************************************
From: Greg Brown <[email protected]>
To: [email protected]
Date: 10/28/2010 07:58 PM
Subject: Re: [Inquires]Data binding for list button.
Is there a value with a key of "id" in your bind context?
On Oct 28, 2010, at 6:33 AM, [email protected] wrote:
>
> Hi All,
>
> I would like use Data binding for list button for simple data.but it
> doesn't work.
>
> I just change this segment,but can't load the id to listButton.
>
> <ListButton selectedItemKey="imAccount.type"
>
> listData="['AIM', 'Jabber', 'Yahoo']"/>
> from
>
>
>
> <ListButton selectedItemKey="id"/>
>
|--------------------------------------------------------------------------|
> |Form wtkx:id="form" styles="{showFlagIcons:false}">
|
> | <sections>
|
> | <Form.Section>
|
> | <Label wtkx:id="sourceLabel"
|
> |Form.label="Source" styles="{font:{italic:true}}"/>
|
> |
|
> | <Label Form.label="ID" textKey="id"/>
|
> | <TextInput Form.label="Name"
|
> |textKey="name"/>
|
> |
|
> | <BoxPane Form.label="Address"
|
> |orientation="vertical">
|
> | <TextInput textKey="name"
|
> |prompt="Street"/>
|
> | <BoxPane>
|
> | <TextInput
textKey="address.city" |
> |prompt="City"/>
|
> | <TextInput
textKey="address.state"|
> |textSize="6" prompt="State"/>
|
> | <TextInput textKey="address.zip"
|
> |textSize="6" prompt="Zip"/>
|
> | </BoxPane>
|
> | </BoxPane>
|
> |
|
> | <TextInput Form.label="Phone"
|
> |textKey="phoneNumber"/>
|
> | <TextInput Form.label="Email"
|
> |textKey="emailAddress"/>
|
> |
|
> | <BoxPane Form.label="IM">
|
> | <TextInput textKey="imAccount.id"/>
|
> | <ListButton selectedItemKey="id"
|
> | />
|
> | </BoxPane>
|
> | </Form.Section>
|
> | </sections>
|
> | </Form>
|
>
|--------------------------------------------------------------------------|
>
>
> Best regards,
> Ken Jiang
>
> *******************************************
> Murata Electronics Trading (Shenzhen) Co.,Ltd
> Tel:86-755-82847251
> E-mail:[email protected]
> *******************************************
>