Make sure that you have registered a class alias for your ActionScript 
representation of the Formasi class. You can do so like this:
 
 
package bkn.pojo
{
 
[RemoteClass[(alias="bkn.pojo.Formasi")]
public class Formasi
{
 
...
 
}
}
 
You also need to make sure you have a reference to the Formasi class in your 
ActionScript code so that it is linked into the SWF at compile time. There are 
several ways to do this. The usual way is to import it and then declare a 
private static variable of the type you want to create a dependency. Another 
way would be to ensure you're using it in your code somewhere such as a casting 
statement or as a type of a function argument etc...
 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jon 
Santos
Sent: Monday, August 27, 2007 4:33 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re: DataGrid with labelfunction + POJO


Hi again.
 
I have tried to make like you told me before :
 
import bkn.pojo.Formasi;

public function getInstansiNama(item:Object, column:DataGridColumn):String

{ 

var myPOJOFormasi:Formasi = Formasi(item);

Alert.show("Instansi : " + myPOJOFormasi.instansi);

return "PPP"; 

}

 

The value of the instansi : NULL

 

Here i send to you the source of the function where i get the Formasi List, 
because i use that function in dataProvider of my DataGrid:

 

public Formasi[] getFormasi( String pTahun ) 

throws ClassNotFoundException, SQLException

{

Formasi[] myFormasi = null ;

try

{

Configuration cfg = new Configuration ();

cfg.configure(); 

SessionFactory sessions = cfg.buildSessionFactory();

Session session = sessions.openSession();

Criteria crit = session.createCriteria(Formasi.class);

Integer iTahun = Integer.valueOf(pTahun);

crit.add( Restrictions.eq("tahun", iTahun));

crit.setMaxResults(10);

java.util.List formasis = crit.list();

myFormasi = new Formasi [formasis.size()];

formasis.toArray(myFormasi);

 

//Here the result never is NULL, always have the correct data

System.out.println("+++ Despues de load: " + 
myFormasi[0].getInstansi().getNama());

 

return myFormasi;

}

catch (Exception ex)

{

System.out.println("Exception " + ex.getMessage());

}

finally

{

return myFormasi;

}

}

 
Thanks in advance
 

 
----- Original Message ----
From: simonjpalmer <[EMAIL PROTECTED]>
To: flexcoders@yahoogroups.com
Sent: Sunday, August 26, 2007 10:11:05 AM
Subject: [flexcoders] Re: DataGrid with labelfunction + POJO



what happens if you cast item to a FormasiFlex, e.g.

FormasiFlex( item).istansi;

--- In [EMAIL PROTECTED] ups.com <mailto:flexcoders%40yahoogroups.com> , Jon 
Santos <[EMAIL PROTECTED]> wrote:
>
> If i put one Alert to display ITEM, the value is : item : [object
FormasiFlex]
> 
> This is the code i have using to see the value of the ITEM object:
> 
> public function myInstansiNama( item:Object,
column:DataGridColu mn):String
> { 
> Alert.show(" item : " + item.toString( )); 
> return item.toString( );
> }
> 
> In the attached file i send to you one screenshot, you will see my
problem.
> 
> If someone can help me.......thaks in advance.
> 
> 
> 
> 
> ----- Original Message ----
> From: Jon Santos <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED] ups.com <mailto:flexcoders%40yahoogroups.com> 
> Sent: Thursday, August 23, 2007 8:13:04 PM
> Subject: Re: [flexcoders] Re: DataGrid with labelfunction + POJO
> 
> My MXML file is like that :
> 
> <?xml version="1.0" encoding="utf- 8"?>
> <mx:Application xmlns:mx="http://www.adobe. <http://www.adobe./>  com/2006/ 
> mxml"
layout="absolute" xmlns:ns1="war. pruebas. *" creationComplete=
"ActivateEvents( )">
> <mx:Script>
> <![CDATA[
> import bkn.pojo.InstansiPe merintah;
> import mx.core.IDataRender er;
> import mx.events.FlexEvent ;
> import mx.core.Container;
> import mx.controls. Alert;
> import mx.collections. ArrayCollection;
> import mx.containers. *;
> import mx.validators. NumberValidator;
> /* [Bindable]
> [RemoteClass( alias="bkn. pojo.JenisFormas i")]
> public class JenisFormasi
> {
> public var kode:String;
> public var deskripsi:String;
> } */
> private var AddOrEdit:String;
> private var DosActivated: Boolean = false;
> private function lihatTahun() :void
> {
> this.srv.getFormasi (this.txtTahun. text) ;
> }
> private function ActivateEvents( ):void
> {
> this.dos.addEventLi sten er(FlexEvent. CREATION_ COMPLETE, setValues) ;
> }
> private function setValues(e: FlexEvent) :void
> {
> this.AddEdit( );
> } 
> private function ActionAdd(): void
> {
> this.AddOrEdit = "Add";
> this.vs.selectedChi ld = dos;
> if (this.DosActivated)
> {
> this.AddEdit( );
> }
> }
> private function InsertFormasi ():void
> {
> }
> private function ActionEdit() :void
> {
> this.AddOrEdit = "Edit";
> this.vs.selectedChi ld = dos; 
> if (this.DosActivated)
> {
> this.AddEdit( );
> }
> }
> public function AddEdit():void
> {
> if (this.AddOrEdit != "Edit") {
> this.myFormasi. tahun. text = "";
> this.myFormasi. jumlah. text = "";
> this.myFormasi. tanggalM enpan.text = "";
> this.myFormasi. Instansi Nama.text = ""; 
> }
> else {
> this.myFormasi. tahun. text = this.dg.selectedIte m. tahun;
> this.myFormasi. jumlah. text = this.dg.selectedIte m. jumlah;
> this.myFormasi. tanggalM enpan.text = this.dg.selectedIte m.
tanggalMenpan;
> this.myFormasi. Instansi Nama.text = this.dg.selectedIte m. nomorMenpan; 
> }
> this.DosActivated = true;
> }
> public function ReturnToStart( ):void
> {
> this.vs.selectedChi ld = cero;
> }
> public function myLabelFunc( item:Object, column:DataGridColu
mn):String{
> return item[column. dataField] .toDateString( );
> //return item[column. datafield] .toDateString( );
> }
> //cliente seleccionado
> public function myInstansiNama( item:Object, column:DataGridColu
mn):String
> { 
> Alert.show(" item.instansi : " + item.instansi) ; 
> return "Jon";
> }
> ]]>
> </mx:Script>
> <mx:RemoteObject id="srv" showBusyCursor= "true" destination= "pojo" />
> <mx:NumberValidator source="{txtTahun} " property="text"
invalidCharError= "This is not a number" integerError= "Masukan
Integer value"
> minValue="1900" maxValue="2007" domain="int" 
> trigger="{btnLihatT ahun}" triggerEvent= "click"
> valid="lihatTahun( )"/>
> <mx:ViewStack id="vs" width="100%" height="90%" right="0" bottom="0">
> <mx:Canvas id="cero" label="cero" width="100%" height="90%" >
> <mx:TextInput width="46" top="31" id="txtTahun" left="139"/>
> <mx:Label text="Tahun Anggaran" width="103" top="33" left="39"/>
> <mx:Button id="btnLihatTahun" label="Lihat" top="31"
icon="@Embed( source= '/war/icons/ camera_edit. png')" left="193"/>
> <mx:Label text="Jumlah Formasi" width="103" left="39" top="59"/>
> <mx:TextArea height="19" width="48" top="59" left="137"/>
> <mx:DataGrid id="dg" dataProvider= "{srv.getFormasi. lastResult}"
top="89" left="26" right="25" bottom="90" borderColor= "#000000"
alternatingItemColo rs="[#f9fcb4, #d5ced3]" cornerRadius= "10"
borderStyle= "solid">
> <mx:columns>
> <mx:DataGridColumn headerText=" Tahun" dataField="tahun" width="60"/>
> <mx:DataGridColumn headerText=" Jumlah" dataField="jumlah" width="60"/>
> <mx:DataGridColumn headerText=" Instansi" labelFunction=
"myInstansiNama" dataField="instansi " width="160"/ >
> <mx:DataGridColumn headerText=" Keputusan Menpan"
dataField="nomorMen pan" width="60"/>
> <mx:DataGridColumn headerText=" Tgl.Kep" labelFunction= "myLabelFunc"
dataField="tanggalM enpan" width="60"/>
> </mx:columns>
> </mx:DataGrid>
> <mx:Button label="Lihat Data" icon="@Embed( source= '/war/icons/
camera_edit. png')" height="22" left="24" bottom="60"/ >
> <mx:Button label="Cari Instansi" left="137" height="22" bottom="60"/ >
> <mx:Canvas height="42" bottom="10" backgroundColor= "#FFFFFF"
left="26" right="25">
> <mx:Button id="add" label="Tambah" width="78" borderColor= "#FF0000"
horizontalCenter= "-150" bottom="10" click="ActionAdd( )"/>
> <mx:Button id="edit" y="10" label="Ubah" width="78" borderColor=
"#FF0000" horizontalCenter= "-46" click="ActionEdit( )"/>
> <mx:Button y="10" label="Hapus" width="78" borderColor= "#FF0000"
horizontalCenter= "50"/>
> <mx:Button label="Kembali" width="78" borderColor= "#FF0000"
horizontalCenter= "149" bottom="10"/ >
> </mx:Canvas>
> </mx:Canvas>
> <mx:Canvas id="dos" label="dos" width="100%" height="100% ">
> <ns1:CompFormasi id="myFormasi" horizontalCenter= "0"
verticalCenter= "7" width="394">
> </ns1:CompFormasi>
> </mx:Canvas>
> </mx:Application>
> 
> 
> When i execute, i can not get any data.
> 
> 
> 
> ----- Original Message ----
> From: simonjpalmer <simonjpalmer@ yahoo.com>
> To: [EMAIL PROTECTED] ups.com
> Sent: Thursday, August 23, 2007 8:05:01 PM
> Subject: [flexcoders] Re: DataGrid with labelfunction + POJO
> 
> 
> is your label function in the script block of the same mxml component
> which has the datagrid?
> 
> What hppens if you set a breakpoint inside myInstansiNama? What is in
> item?
> 
> --- In [EMAIL PROTECTED] ups.com, "txakin" <txakin@> wrote:
> >
> > Hi,
> > 
> > I´m new using Flex.
> > My application will use Flex + Java + Hibernate (POJO)
> > 
> > 
> > I have create one Datagrid, to display some data :
> > 
> > <mx:DataGrid id="dg" dataProvider= "{srv.getFormasi .lastResult} " 
> > top="89" left="26" right="25" 
> > bottom="90" borderColor= "#000000" 
> > alternatingItemColo rs="[#f9fcb4, #d5ced3]" 
> > cornerRadius= "10" borderStyle= "solid">
> > 
> > <mx:columns>
> > <mx:DataGridColumn headerText=" Tahun" dataField="tahun" width="60"/>
> > <mx:DataGridColumn headerText=" Jumlah" dataField="jumlah" 
> > width="60"/>
> > <mx:DataGridColumn headerText=" Instansi" 
> > labelFunction= "myInstansiNama" 
> > dataField="instansi " width="160"/ >
> > <mx:DataGridColumn headerText=" Keputusan Menpan" 
> > dataField="nomorMen pan" width="60"/>
> > <mx:DataGridColumn headerText=" Tgl.Kep" labelFunction= "myLabelFunc" 
> > dataField="tanggalM enpan" width="60"/>
> > </mx:columns>
> > 
> > </mx:DataGrid>
> > 
> > 
> > To display the data in the datagrid i get the data in one FORMASI 
> > Pojo....untill here all the things are correct...i can display my 
> > data.
> > 
> > The problem is when i try to display in the INSTANSI datafield the 
> > INSTANSIPEMERINTAH nama........ .here i send you how are my Pojos 
> > develpoed:
> > 
> > package bkn.pojo;
> > import java.io.Serializabl e;
> > public class Formasi implements Serializable {
> > private String formasiId;
> > private InstansiPemerintah instansi;
> > private int tahun;
> > private String nomorMenpan;
> > private Date tanggalMenpan;
> > private int jumlah;
> > 
> > ......... Methods GET and SET ............
> > }
> > 
> > And I have the InstansiPemerintah POJO
> > 
> > package bkn.pojo;
> > import java.io.Serializabl e;
> > public class InstansiPemerintah implements Serializable {
> > private String instansiPemerintahI d;
> > private String kode;
> > private String nama;
> > 
> > ....... Methods GET and SET ...........
> > }
> > 
> > In my MXML I have created the next function to get the name of the 
> > instansi datafield
> > 
> > import war.classes2. InstansiPemerint ah;
> > public function myInstansiNama( item:Object, 
> > column:DataGridColu mn):String
> > { 
> > return item.instansi. nama;
> > }
> > 
> > To use my POJO in the MXML i have created 2 ActionScript files:
> > 
> > package war.classes2
> > {
> > [Bindable]
> > [RemoteClass( alias="bkn. pojo.Formasi" )]
> > public class Formasi
> > {
> > public formasiId:String;
> > public instansi:InstansiPe merintah;
> > public tahun:int;
> > public nomorMenpan: String;
> > public tanggalMenpan: Date;
> > public jumlah:int; 
> > 
> > }
> > }
> > 
> > package war.classes2
> > {
> > [Bindable]
> > [RemoteClass( alias="bkn. pojo.InstansiPem erintah") ]
> > public class InstansiPemerintah
> > {
> > public var instansiPemerintahI d:String;
> > public var kode:String;
> > public var nama:String; 
> > 
> > }
> > }
> > 
> > 
> > But when I try to execute it, I never get any data.
> > Please, can you help me?
> > 
> > Thanks in advance.
> >
> 
> 
> 
> 
> 
> 
> 
> Ready for the edge of your seat? Check out tonight's top picks on
Yahoo! TV. 
> 
> 
> 
> 
>
____________ _________ _________ _________ _________ _________ _
> Got a little couch potato? 
> Check out fun summer activities for kids.
>
http://search. yahoo.com/ search?fr= oni_on_mail& p=summer+ activities+ 
for+kids& cs=bz 
<http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&cs=bz>
 
>





________________________________

Shape Yahoo! in your own image. Join our Network Research Panel today! 
<http://us.rd.yahoo.com/evt=48517/*http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7>
   

Reply via email to