You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by lello <rb...@gmail.com> on 2011/01/31 10:21:08 UTC

Accessing subclass in bxml

Hi again,
in my code I have a cell renderer class inside a main class

class MyObject {

  public class MyCellRenderer() {
  }

}

is it possible to specify MyCellRenderer in a bxml file?

Thanks,
Lello



-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Accessing-subclass-in-bxml-tp2388480p2388480.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Accessing subclass in bxml

Posted by lello <rb...@gmail.com>.
Thanks! My inner class is static indeed (I've just forgot to add it in the
example), so your example is perfect.
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Accessing-subclass-in-bxml-tp2388480p2389408.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Accessing subclass in bxml

Posted by Chris Bartlett <cb...@gmail.com>.
Make MyCellRenderer static, and ensure that there is an accessible a
no-argument constructor.

"bxml.bxml"
<MyObject.MyCellRenderer xmlns="lello" xmlns:bxml="
http://pivot.apache.org/bxml" name="blah" />

"MyObject.java"
package lello;

import java.io.IOException;

import org.apache.pivot.beans.BXMLSerializer;
import org.apache.pivot.serialization.SerializationException;

public class MyObject {

public static class MyCellRenderer {
private String name = "default";
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}


public static void main(String[] args) {
BXMLSerializer serializer = new BXMLSerializer();
try {
Object serialized = serializer.readObject(MyObject.class, "bxml.bxml");
if (serialized instanceof MyCellRenderer) {
MyCellRenderer mcr = (MyCellRenderer)serialized;
System.out.println(mcr.getName());
}
} catch (IOException e) {
e.printStackTrace();
} catch (SerializationException e) {
e.printStackTrace();
}
}
}


Chris
On 31 January 2011 16:21, lello <rb...@gmail.com> wrote:

> class MyObject {
>
>  public class MyCellRenderer() {
>  }
>
> }
>