You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Alejandro Vilar <al...@synacom.com.bo> on 2010/11/05 19:47:06 UTC

Question about porting resources from wtkx to bxml

Hi all,
	We have a pivot app based on version 1.4, now we are planning to port
it to version 2.0 (when released) in the middle time we are working with
lastest svn revision. Now the problem is with the resources usages in
bxml files, eg:

<PushButton buttonData="%some.button.label">

This shows "some.button.label" instead the real value in the json file.
So this feature is no longer supported? or is there a better way to
acomplish this task?

Thanks in advance,

-A


Re: Question about porting resources from wtkx to bxml

Posted by Alejandro Vilar <al...@synacom.com.bo>.
It works, thanks Greg.

-A
El vie, 05-11-2010 a las 18:10 -0400, Greg Brown escribió:
> I think I see the problem. Don't call setResources() yourself - use the following readObject() signature:
> 
> serializer.readObject(Main.class.getResource("main.bxml"), 
>     new Resources("sample.Bundle"));
> 
> The readObject() overload that just takes a URL delegates to this one but passes null for the Resources argument, so your original resources are being ignored.
> 
> Greg
> 
> On Nov 5, 2010, at 5:58 PM, Alejandro Vilar wrote:
> 
> > Hi Greg, I have an example here, the button and the window's title shows
> > "some.button.label" instead "Foo"
> > 
> > (Compiled with the last svn revision)
> > 
> > JSON:
> > 
> > {
> >    "some":{
> >        "button":{
> >            "label":"Foo"
> >        }
> >    }
> > }
> > 
> > 
> > BXML:
> > 
> > <?xml version="1.0" encoding="UTF-8"?>
> > <Frame xmlns:bxml="http://pivot.apache.org/wtkx"
> > xmlns="org.apache.pivot.wtk"
> >    bxml:id="frame" maximized="true" title="%some.button.label">
> >    <content>
> >        <PushButton buttonData="%some.button.label"/>
> >    </content>
> > </Frame>
> > 
> > 
> > Java:
> > 
> > package sample;
> > import org.apache.pivot.beans.*;
> > import org.apache.pivot.collections.Map;
> > import org.apache.pivot.util.Resources;
> > import org.apache.pivot.wtk.*;
> > 
> > public class Main implements Application {
> > 
> >    private Window window;
> >    @BXML private Frame frame;
> > 
> >    public static void main(String[] args) {
> >        DesktopApplicationContext.main(Main.class, args);
> >    }
> > 
> >    public void startup(Display display, Map<String, String> properties)
> > throws Exception {
> >        Resources resources = new Resources("sample/bundle");
> >        BXMLSerializer serializer = new BXMLSerializer();
> >        serializer.setResources(resources);
> >        serializer.readObject(Main.class.getResource("main.bxml"));
> >        serializer.bind(this, Main.class);
> >        window = new Window();
> >        window.open(display);
> >        frame.open(window);
> >    }
> > 
> >    public boolean shutdown(boolean optional) throws Exception {
> >        if (window != null) {
> >            window.close();
> >        }
> >        return false;
> >    }
> > 
> >    public void suspend() throws Exception {
> >    }
> > 
> >    public void resume() throws Exception {
> >    }
> > }
> > 
> > Regards,
> > 
> > Alejandro
> > 
> > El vie, 05-11-2010 a las 15:30 -0400, Greg Brown escribió:
> >> No, that should still work. Can you share a code sample that demonstrates the problem?
> >> 
> >> On Nov 5, 2010, at 2:47 PM, Alejandro Vilar wrote:
> >> 
> >>> Hi all,
> >>> 	We have a pivot app based on version 1.4, now we are planning to port
> >>> it to version 2.0 (when released) in the middle time we are working with
> >>> lastest svn revision. Now the problem is with the resources usages in
> >>> bxml files, eg:
> >>> 
> >>> <PushButton buttonData="%some.button.label">
> >>> 
> >>> This shows "some.button.label" instead the real value in the json file.
> >>> So this feature is no longer supported? or is there a better way to
> >>> acomplish this task?
> >>> 
> >>> Thanks in advance,
> >>> 
> >>> -A
> >>> 
> >> 
> > 
> > 
> 



Re: Question about porting resources from wtkx to bxml

Posted by Greg Brown <gk...@mac.com>.
I think I see the problem. Don't call setResources() yourself - use the following readObject() signature:

serializer.readObject(Main.class.getResource("main.bxml"), 
    new Resources("sample.Bundle"));

The readObject() overload that just takes a URL delegates to this one but passes null for the Resources argument, so your original resources are being ignored.

Greg

On Nov 5, 2010, at 5:58 PM, Alejandro Vilar wrote:

> Hi Greg, I have an example here, the button and the window's title shows
> "some.button.label" instead "Foo"
> 
> (Compiled with the last svn revision)
> 
> JSON:
> 
> {
>    "some":{
>        "button":{
>            "label":"Foo"
>        }
>    }
> }
> 
> 
> BXML:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <Frame xmlns:bxml="http://pivot.apache.org/wtkx"
> xmlns="org.apache.pivot.wtk"
>    bxml:id="frame" maximized="true" title="%some.button.label">
>    <content>
>        <PushButton buttonData="%some.button.label"/>
>    </content>
> </Frame>
> 
> 
> Java:
> 
> package sample;
> import org.apache.pivot.beans.*;
> import org.apache.pivot.collections.Map;
> import org.apache.pivot.util.Resources;
> import org.apache.pivot.wtk.*;
> 
> public class Main implements Application {
> 
>    private Window window;
>    @BXML private Frame frame;
> 
>    public static void main(String[] args) {
>        DesktopApplicationContext.main(Main.class, args);
>    }
> 
>    public void startup(Display display, Map<String, String> properties)
> throws Exception {
>        Resources resources = new Resources("sample/bundle");
>        BXMLSerializer serializer = new BXMLSerializer();
>        serializer.setResources(resources);
>        serializer.readObject(Main.class.getResource("main.bxml"));
>        serializer.bind(this, Main.class);
>        window = new Window();
>        window.open(display);
>        frame.open(window);
>    }
> 
>    public boolean shutdown(boolean optional) throws Exception {
>        if (window != null) {
>            window.close();
>        }
>        return false;
>    }
> 
>    public void suspend() throws Exception {
>    }
> 
>    public void resume() throws Exception {
>    }
> }
> 
> Regards,
> 
> Alejandro
> 
> El vie, 05-11-2010 a las 15:30 -0400, Greg Brown escribió:
>> No, that should still work. Can you share a code sample that demonstrates the problem?
>> 
>> On Nov 5, 2010, at 2:47 PM, Alejandro Vilar wrote:
>> 
>>> Hi all,
>>> 	We have a pivot app based on version 1.4, now we are planning to port
>>> it to version 2.0 (when released) in the middle time we are working with
>>> lastest svn revision. Now the problem is with the resources usages in
>>> bxml files, eg:
>>> 
>>> <PushButton buttonData="%some.button.label">
>>> 
>>> This shows "some.button.label" instead the real value in the json file.
>>> So this feature is no longer supported? or is there a better way to
>>> acomplish this task?
>>> 
>>> Thanks in advance,
>>> 
>>> -A
>>> 
>> 
> 
> 


Re: Question about porting resources from wtkx to bxml

Posted by Alejandro Vilar <al...@synacom.com.bo>.
Hi Greg, I have an example here, the button and the window's title shows
"some.button.label" instead "Foo"

(Compiled with the last svn revision)

JSON:

{
    "some":{
        "button":{
            "label":"Foo"
        }
    }
}


BXML:

<?xml version="1.0" encoding="UTF-8"?>
<Frame xmlns:bxml="http://pivot.apache.org/wtkx"
xmlns="org.apache.pivot.wtk"
    bxml:id="frame" maximized="true" title="%some.button.label">
    <content>
        <PushButton buttonData="%some.button.label"/>
    </content>
</Frame>


Java:

package sample;
import org.apache.pivot.beans.*;
import org.apache.pivot.collections.Map;
import org.apache.pivot.util.Resources;
import org.apache.pivot.wtk.*;

public class Main implements Application {

    private Window window;
    @BXML private Frame frame;

    public static void main(String[] args) {
        DesktopApplicationContext.main(Main.class, args);
    }

    public void startup(Display display, Map<String, String> properties)
throws Exception {
        Resources resources = new Resources("sample/bundle");
        BXMLSerializer serializer = new BXMLSerializer();
        serializer.setResources(resources);
        serializer.readObject(Main.class.getResource("main.bxml"));
        serializer.bind(this, Main.class);
        window = new Window();
        window.open(display);
        frame.open(window);
    }

    public boolean shutdown(boolean optional) throws Exception {
        if (window != null) {
            window.close();
        }
        return false;
    }

    public void suspend() throws Exception {
    }

    public void resume() throws Exception {
    }
}

Regards,

Alejandro

El vie, 05-11-2010 a las 15:30 -0400, Greg Brown escribió:
> No, that should still work. Can you share a code sample that demonstrates the problem?
> 
> On Nov 5, 2010, at 2:47 PM, Alejandro Vilar wrote:
> 
> > Hi all,
> > 	We have a pivot app based on version 1.4, now we are planning to port
> > it to version 2.0 (when released) in the middle time we are working with
> > lastest svn revision. Now the problem is with the resources usages in
> > bxml files, eg:
> > 
> > <PushButton buttonData="%some.button.label">
> > 
> > This shows "some.button.label" instead the real value in the json file.
> > So this feature is no longer supported? or is there a better way to
> > acomplish this task?
> > 
> > Thanks in advance,
> > 
> > -A
> > 
> 



Re: Question about porting resources from wtkx to bxml

Posted by Greg Brown <gk...@mac.com>.
No, that should still work. Can you share a code sample that demonstrates the problem?

On Nov 5, 2010, at 2:47 PM, Alejandro Vilar wrote:

> Hi all,
> 	We have a pivot app based on version 1.4, now we are planning to port
> it to version 2.0 (when released) in the middle time we are working with
> lastest svn revision. Now the problem is with the resources usages in
> bxml files, eg:
> 
> <PushButton buttonData="%some.button.label">
> 
> This shows "some.button.label" instead the real value in the json file.
> So this feature is no longer supported? or is there a better way to
> acomplish this task?
> 
> Thanks in advance,
> 
> -A
>