Re: [flexcoders] Re: DataGrid with labelfunction + POJO

2007-08-27 Thread Jon Santos
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, 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
 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. 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

RE: [flexcoders] Re: DataGrid with labelfunction + POJO

2007-08-27 Thread Peter Farland
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