I'm following a flex application tutorial, and while I've been able to fix most of my errors, this one has me completely stumped.
I have a datatable called employees, with these columns: id, Firstname, Lastname, Title, Birthday, Cellphone, Officephone, Email, Address, photofile.
The application is simple: list all the employees in the HomeView, and when you tap on an employee, takes you to DetailView where you see all their extra info. Every time I do, however, I get: "ReferenceError: Error #1056: Cannot create property Address on valueObjects.Employees."
Here's the code for DetailView:
xmlns:employeesservice1="services.employeesservice1.*"
overlayControls="false"
title="{getEmployeesByIDResult.lastResult.Firstname} {getEmployeesByIDResult.lastResult.Lastname}"
viewActivate="view1_viewActivateHandler(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import spark.events.ViewNavigatorEvent;
import mx.rpc.events.ResultEvent;
protected function goBack(event:Event):void
{
navigator.pushView(EmployeeListerHomeView);
}
protected function getEmployeesByID(itemID:int):void
{
getEmployeesByIDResult.token = employeesService1.getEmployeesByID(itemID);
}
protected function view1_viewActivateHandler(event:ViewNavigatorEvent):void
{
this.addElement(busyIndicator);
getEmployeesByID(data as int);
}
protected function getAllEmployeesResult_resultHandler(event:ResultEvent):void
{
this.removeElement(busyIndicator);
}
]]>
</fx:Script>
<fx:Declarations>
<s:CallResponder id="getEmployeesByIDResult" result="getAllEmployeesResult_resultHandler(event)"/>
<employeesservice1:EmployeesService1 id="employeesService1"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:navigationContent>
<s:Button id="backBtn" click="goBack(event)">
<s:icon>
<s:MultiDPIBitmapSource source160dpi="@Embed('assets/save160.png')"
source240dpi="@Embed('assets/save240.png')"
source320dpi="@Embed('assets/save320.png')"/>
</s:icon>
</s:Button>
</s:navigationContent>
<s:Image x="10" y="10" width="100" height="100"
source="http://localhost/EmployeeLister/assets/{getEmployeesByIDResult.lastResult.photofile}128x128.png" />
<s:VGroup width="100%" height="100%" gap="10" paddingLeft="120">
<s:Label fontWeight="bold" paddingTop="10" text="Title"/>
<s:Label text="{getEmployeesByIDResult.lastResult.Title}"/>
<s:Label fontWeight="bold" paddingTop="10" text="Cell Phone"/>
<s:Label text="{getEmployeesByIDResult.lastResult.Cellphone}"/>
<s:Label fontWeight="bold" paddingTop="10" text="Office Phone"/>
<s:Label text="{getEmployeesByIDResult.lastResult.Officephone}"/>
<s:Label fontWeight="bold" paddingTop="10" text="Email"/>
<s:Label text="{getEmployeesByIDResult.lastResult.Email}"/>
<s:Label fontWeight="bold" paddingTop="10" text="Address"/>
<s:Label text="{getEmployeesByIDResult.lastResult.Address}"/>
</s:VGroup>
<s:BusyIndicator id="busyIndicator" verticalCenter="0" horizontalCenter="0" symbolColor="red"/>
Now something to note: I added the Cellphone, Officephone, Email, and Address columns after I had created the EmployeesService1, and so I had to edit the .php to include these new values. So I'm worried I might have done something wrong there, but I triple checked for typos and I'm not getting any errors on the other values, so, I don't know. Again, this has me pretty frustrated. I've tested all the operations in the service, and they're all returning all of the appropriate values.
Here's the function from the .php: public function getEmployeesByID($itemID) {
$stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename where id=?");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'i', $itemID);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
mysqli_stmt_bind_result($stmt, $row->id, $row->Firstname, $row->Lastname, $row->Title, $row->Birthday, $row->Cellphone, $row->Officephone, $row->Email, $row->Address, $row->photofile);
if(mysqli_stmt_fetch($stmt)) {
$row->Birthday = new DateTime($row->Birthday);
return $row;
} else {
return null;
}
}
Even if you don't know the exact answer, are there easier ways for me to figure out what's happening? The call-stack in the error window is all the internal flex/as3 stuff. So I don't want to go down that rabbit hole if I don't have to.
Any help is greatly appreciated. Thanks!!!!
Figured it out.
The problem was in the .php, after each of the generated
getEmployeesBy**()
functions, there's a@return stdClass
.I needed to create a
getEmployeesByName
function, however, and did so in between thegetEmployeesByID()
and the@return stdClass
. So I just put in another@return
between the functions and it's all working cleanly now.