Cannot access a property or method of a null object reference

31 views
Skip to first unread message

Jason Fincanon

unread,
Jun 23, 2011, 1:44:52 PM6/23/11
to gwt4air
I'm trying to do the RPC example and it compiles fine with the GWT
compiler, but as soon as I try to build it as an AIR app, I get the
following (I'm not using DateFormatter or FileSystemDataGrid or any of
the other in there):

TypeError: Error #1009: Cannot access a property or method of a null
object reference.
at mx.formatters::DateFormatter/format()[E:\dev\4.x\frameworks
\projects\framework\src\mx\formatters\DateFormatter.as:607]
at mx.controls::FileSystemDataGrid/creationDateLabelFunction()[E:\dev
\4.x\frameworks\projects\airframework\src\mx\controls
\FileSystemDataGrid.as:1600]
at mx.controls.dataGridClasses::DataGridColumn/itemToLabel()[E:\dev
\4.x\frameworks\projects\framework\src\mx\controls\dataGridClasses
\DataGridColumn.as:1686]
at mx.controls.dataGridClasses::DataGridBase/makeListData()[E:\dev\4.x
\frameworks\projects\framework\src\mx\controls\dataGridClasses
\DataGridBase.as:1485]
at mx.controls::DataGrid/http://www.adobe.com/2006/flex/mx/
internal::setupRendererFromData()[E:\dev\4.x\frameworks\projects
\framework\src\mx\controls\DataGrid.as:1973]
at mx.controls::DataGrid/commitProperties()[E:\dev\4.x\frameworks
\projects\framework\src\mx\controls\DataGrid.as:1928]
at mx.controls::FileSystemDataGrid/commitProperties()[E:\dev\4.x
\frameworks\projects\airframework\src\mx\controls
\FileSystemDataGrid.as:1134]
at mx.core::UIComponent/validateProperties()[E:\dev\4.x\frameworks
\projects\framework\src\mx\core\UIComponent.as:7933]
at mx.managers::LayoutManager/validateProperties()[E:\dev\4.x
\frameworks\projects\framework\src\mx\managers\LayoutManager.as:572]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.x
\frameworks\projects\framework\src\mx\managers\LayoutManager.as:700]
at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev
\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:
1072]

nino

unread,
Jun 23, 2011, 2:02:12 PM6/23/11
to gwt...@googlegroups.com
Do you please  have a testcase implementing EntryPoint ? 
Best,

Alain

Jason Fincanon

unread,
Jun 23, 2011, 2:31:18 PM6/23/11
to gwt4air
package com.jasonfincanon.airrpc.client;

import
com.ekambi.gwt.air.flx.client.core.framework.FlexInitiaLizationHandler;
import com.ekambi.gwt.air.flx.client.mx.controls.TextInput;
import com.ekambi.gwt.web.core.client.flash.events.Event;
import
com.ekambi.gwt.web.core.client.flash.events.FlashEventListener;
import com.ekambi.gwt.web.core.client.flash.events.MouseEvent;
import com.ekambi.gwt.air.flx.client.core.framework.FLEX;
import com.ekambi.gwt.web.flex.client.mx.containers.ControlBar;
import com.ekambi.gwt.web.flex.client.mx.containers.Form;
import com.ekambi.gwt.web.flex.client.mx.containers.FormItem;
import com.ekambi.gwt.web.flex.client.mx.containers.Panel;
import com.ekambi.gwt.web.flex.client.mx.controls.Alert;
import com.ekambi.gwt.web.flex.client.mx.controls.Button;
import com.ekambi.gwt.web.flex.client.mx.controls.Spacer;
import com.ekambi.gwt.web.flex.client.mx.core.ContainerLayout;
import
com.ekambi.gwt.web.flex.client.mx.events.ValidationResultEvent;
import com.ekambi.gwt.web.flex.client.mx.validators.StringValidator;
import com.ekambi.gwt.web.flex.client.spark.components.Application;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class AirRpc implements EntryPoint {

private TextInput textInput;
private final String NAME_IS_REQUIRED = "You must enter a name";
private final String GWT_RPC_WITH_FLEX = "GWT RPC with Adobe Flex
UI";
private final String WARNING = "Warning";
private final String ERROR = "Error";

/**
* The message displayed to the user when the server cannot be
reached or
* returns an error.
*/
private final String SERVER_ERROR = "An error occurred while "
+ "attempting to contact the server. Please check your network
"
+ "connection and try again.";

/**
* Create a remote service proxy to talk to the server-side Greeting
service.
*/
private final GreetingServiceAsync greetingService =
GWT.create(GreetingService.class);


public void onModuleLoad() {

FLEX.init(new FlexInitiaLizationHandler() {

@Override
protected void onInitialization() {
Panel panel = Panel.newInstance("Flex and GWT RPC example");
panel.setPercentHeight(50);
panel.setPercentWidth(50);
panel.setVerticalCenter(0);
panel.setHorizontalCenter(0);
panel.setLayout(ContainerLayout.ABSOLUTE);

Form form = Form.newInstance();
form.setHorizontalCenter(0);
form.setVerticalCenter(0);
panel.addElement(form);

FormItem item = FormItem.newInstance();
item.setLabel("Enter your name :");
item.setRequired(true);
form.addElement(item);

textInput = TextInput.newInstance();
textInput.setWidth(200);
//item.addElement(textInput); //The method
addElement(UIComponent) in the type Container is not applicable for
the arguments (TextInput)

Button submitButton = Button.newInstance("Submit");
submitButton.setHeight(40);

StringValidator validator =
StringValidator.newInstance();
validator.setSource(textInput);
validator.setProperty("text");
validator.setTrigger(submitButton);
validator.setTriggerEvent(MouseEvent.CLICK);

validator.addEventListener(ValidationResultEvent.VALID, new
FlashEventListener<Event>() {
@Override
protected void onFlashEvent(Event event) {
sendToServer(textInput.getHtmlText());
}

});

validator.addEventListener(ValidationResultEvent.INVALID, new
FlashEventListener<Event>() {
@Override
protected void onFlashEvent(Event event) {
Alert.show(NAME_IS_REQUIRED, WARNING,
Alert.OK, Application.get());
}

});

ControlBar controlBar = ControlBar.newInstance();
Spacer spacer = Spacer.newInstance();
spacer.setPercentWidth(100);
controlBar.addElement(spacer);
controlBar.addElement(submitButton);

Application.get().addElement(panel);
panel.addElement(controlBar);

}
});

}

private void sendToServer(String text) {
greetingService.greetServer(text, new AsyncCallback<String>()
{
@Override
public void onSuccess(String result) {
Alert.show(result, GWT_RPC_WITH_FLEX, Alert.OK,
Application.get());
}

@Override
public void onFailure(Throwable caught) {
Alert.show(SERVER_ERROR, ERROR, Alert.OK,
Application.get());
}
});

nino

unread,
Jun 23, 2011, 3:04:39 PM6/23/11
to gwt...@googlegroups.com
You are mixing the AIR elements with the web Elements. That s the problem

If you are building an AIR application  make sure that everything is coming from  com.ekambi.gwt.air
you can not have anything from  com.ekambi.gwt.web in there. and vice versa



cheers,

Alain 


Jason Fincanon

unread,
Jun 23, 2011, 4:02:09 PM6/23/11
to gwt4air
Ah ha! That solved it. Thank you, sir. :)
I'll keep you posted on my progress.

-Jason

On Jun 23, 2:04 pm, nino <jazzmatad...@googlemail.com> wrote:
> You are mixing the AIR elements with the web Elements. That s the problem
>
> If you are building an AIR application  make sure that *everything is coming
> from  com.ekambi.gwt.air*
> you can not have anything from  *com.ekambi.gwt.web* in there. and vice

nino

unread,
Jun 23, 2011, 4:17:37 PM6/23/11
to gwt...@googlegroups.com
Glad that could help.
Hit me anytime when you have an issue.
Thx for using gwt4air
Reply all
Reply to author
Forward
0 new messages