pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ilya Zimnovich <zimnov...@gmail.com>
Subject Unserialize an object in class constructor
Date Mon, 24 Mar 2014 16:26:26 GMT
Dear Apache Pivot experts,

All the Apache Pivot examples unserialize an objects with
BXMLSerializer's readObject method:

....
    public void startup(Display display, Map<String, String> properties)
throws Exception
    {
        String language = properties.get("language");
        Locale locale = (language == null) ? Locale.getDefault() : new
Locale(language);
        Resources resources = new
Resources(FinanceWindow.class.getName(), locale);
       
        BXMLSerializer bxmlSerializer = new BXMLSerializer();
        window =
(FinanceWindow)bxmlSerializer.readObject(getClass().getResource("FinanceWindow.bxml"),
resources);
        window.open(display);
    }
....

Is there a way to unserialize the object in its constructor? I mean
something like the below:

....
    public void startup(Display display, Map<String, String> properties)
throws Exception
    {
        window = new FinanceWindow();
        window.open(display);
    }
....

public class FinanceWindow extends Frame implements Bindable
{
....

    public FinanceWindow()
    {
        BXMLSerializer bxmlSerializer = new BXMLSerializer();

        // Load localized resources and unserialize the object
        String language = properties.get("language");
        Locale locale = (language == null) ? Locale.getDefault() : new
Locale(language);
        Resources resources = new Resources(getClass().getName(), locale);

        bxmlSerializer.readObjectXXXX(this, "FinanceWindow.bxml");

....


Best Regards,
Ilya A. Zimnovich

Mime
View raw message