Development of Flex Blog system from zero based on FLEX4 technology: 5 data storage Management greeting

Source: Internet
Author: User

Google App Engine for Java has been open since April 7 this year, less than 20th, but there have been many blog posts about Gae for Java. After data storage, this lesson is to study how to manage greeting through the client, that is, curd implementation.

One, the list shows

Add an interface to get all greeting in Sban.flexblog.HelloWorld.java:

public List<Greeting> getAllGreetings() {
 List<Greeting> result;
   try {
         result = (List<Greeting>) pm.newQuery(Greeting.class).execute();
       } finally {
            pm.close();
       }

       return result;
 }

In the example above, Pm.newquery (Greeting.class) is responsible for querying all the stored greeting information. The List data is mapped to ArrayList in the Flex client.

Modify the Index.mxml client code, after which the final code is as follows:

<?xml version= "1.0" encoding= "Utf-8"?>
<fxapplication xmlns= "http://ns.adobe.com/mxml/2009" initialize= "OnInit ()" >
<Script>
<! [cdata[
Import Mx.controls.Alert;
Import Flash.net.URLLoader;
Import Flash.net.URLRequest;
Import mx.rpc.events.ResultEvent;
Import mx.rpc.events.FaultEvent;
Import mx.rpc.AbstractOperation;
Import Mx.rpc.remoting.RemoteObject;
Import Mx.messaging.ChannelSet;
Import Mx.messaging.channels.AMFChannel;
Import mx.collections.ArrayCollection;
Import Mx.managers.CursorManager;
Import Mx.events.IndexChangedEvent

[bindable]
private Var _greetingdata:arraycollection;

[bindable]
private Var _greeting:object;

private var _remotingobj:remoteobject = new RemoteObject ("Genericdestination");

Private Function OnInit (): void
{
Configremoting ();
Getallgreetings ();
}

Private Function configremoting (): void
{
_remotingobj.source = "Sban.flexblog.HelloWorld";
_remotingobj.endpoint = "Weborb.wo";
}

Private Function greetviaremoting (): void
{
var op:abstractoperation = _remotingobj.getoperation ("Greet2");
var handler:function = Function (event:resultevent): void
{
Op.removeeventlistener (Resultevent.result, handler);
Getallgreetings ();
Alert.show (Event.result.toString ());
};

Op.addeventlistener (Resultevent.result, handler);
Op.send (Vnametxt.text,vcontenttxt.text);
}

Private Function getallgreetings (): void
{
var op:abstractoperation = _remotingobj.getoperation ("getallgreetings");
var handler:function = Function (event:resultevent): void
{
Op.removeeventlistener (Resultevent.result, handler);

_greetingdata = ArrayCollection (Event.result);
};

Op.addeventlistener (Resultevent.result, handler);
Op.send ();
}
]]>
</Script>

<layout>
<basiclayout/>
</layout>

<vgroup width= "100%" >
<HGroup>
<label text= "User:"/>
<fxtextinput id= "Vnametxt" text= "Sban"/>
</HGroup>
<HGroup>
<label text= "content:"/>
<fxtextinput id= "Vcontenttxt" text= "Greeting content"/>
</HGroup>

<HGroup>
<fxbutton id= "vsendbtn" label= "remoting greet" click= "greetviaremoting ()"/>
</HGroup>

<fxlist id= "VList1" dataprovider= "{_greetingdata}" width= "60%" itemrenderer= "Greetingitemrenderer" >
<layout>
<verticallayout/>
</layout>
</FxList>

</VGroup>

<textbox text= "by Sban" color= "Gray" bottom= "ten" right= "ten"/>

</FxApplication>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.