Seriously do flex + spring + blazeDS + google app JDO paging. The total number for each inquiry.

sponsored links
Seriously do flex + spring + blazeDS + google app JDO paging. The total number for each inquiry.

BlazeDS frustrating to die recently ..

A little bit to replace e4x xml format as to the relatively simple. But finally did not give up. Harvest is good.

First, explore inside the dynamic loading using SWFLoader do.

Depending on the menu to display different tab pages.

However, several label switch error when the problem:

*** TypeError: Error # 1034: type cast fails: can not convert Object @ b932bf1 mx.messaging.messages.IMessage.

The search is due to shared library module is loaded.

There are some things not found .. load failure.

http://www.javaeye.com/topic/297813

Refer to the following ..

Practice:

The. / / Var swfLoader: SWFLoader = new SWFLoader ();
/ / SwfLoader.source = nodeApp + ". Swf";
Replaced.
var swfLoader: ModuleLoader = new ModuleLoader ();
Load module.
swfLoader.applicationDomain = ApplicationDomain.currentDomain;
/ / Address [TypeError: Error # 1034: type cast fails:] module loading problem.
swfLoader.loadModule (nodeApp + ". swf");
And application replication.

Successfully loaded multiple modules. .. And began to load the module solved the problem of slow.

BlazeDS is also very fast to use. Seems to insist is right.

Began writing the following pages.

A reference to the previous page into a class as ..

package common.page
{
        import mx.controls.Label;
        import mx.events.ItemClickEvent;
        
        public class PageConf
        {
                /**  Paging class start  .*./ /**  Sort fields  . */
                public var sortField:String;
                /**  Sort Ascending and descending  .des,aesc. */
                public var sortDir:String;
                /**  Paging start  . */
                private var start:Number;
                /**  Paging end  . */
                private var end:Number;
                /**  The maximum number per page  . */
                private var limit:Number;
                /**  The total number of pages  . */
                public var total:Number;
        
                public function getStart():Number {
                        return this.start;
                }
                public function getEnd():Number {
                        // Recalculate every time because the End.  . Is it possible to increase the query time, data  .
                        return Math.min(this.start + this.limit, this.total);
                }
                
                public function getCurrPage():Number {// Get the current page  .
                        return Number(Math.floor(start / limit));
                }
        
                public function getTotalPage():Number {
                        /**  Get the total number of pages  . */
                        return Number(Math.ceil(total / limit));
                }
        
                public function getGo(page:Number):void {/*  Page jump function enter to jump to the page  . */
                        var totalPage:Number = getTotalPage();
                        var currentPage:Number = getCurrPage();
                        if (page <= 1) {/*  If less than 1. go to Home  . */
                                getFirst();
                                return;
                        } else if (page >= totalPage) {/*  If is greater than the total number of pages to jump to the last page  . */
                                getLast();
                                return;
                        } else if (page == currentPage) {/*  Returns the current page  . */
                                return;
                        } else {/*  Otherwise for page jump-that is, calculate the  start And  end. */
                                this.start = (page - 1) * limit;
                                this.end = Math.min(page * limit, total);
                        }
                }
        
                public function getNext():void  {
                        trace("getNextPage");
                        var currentPage:Number = getCurrPage();
                        var tempStart:Number = (currentPage + 1) * limit;
                        if (tempStart >= total)
                                return;
                        this.start = tempStart;
                        this.end = Math.min((currentPage + 2) * limit, total);
                }
        
                public function getFirst():void  {
                        trace("getFirst");
                        this.start = 0;
                        this.end = Math.min(limit, total);
                }
        
                public function getLast():void {
                        trace("getEnd");
                        var lastPage:Number = getTotalPage();
                        /**  If the total number of pages exactly divisible. to the previous page  . */
                        if ((lastPage * limit) >= total) {
                                lastPage--;
                        }
                        this.start = lastPage * limit;
                        this.end = Math.min((lastPage + 1) * limit, total);
                }
        
                public function getPrev():void {
                        trace("getPrevpage");
                        var currentPage:Number = getCurrPage();
                        /**  The previous page is equal to the current pages multiplied by the number of records per page  . */
                        this.start = Math.max((currentPage - 1) * limit, 0);
                        this.end = Math.max((currentPage) * limit, limit);
                }
        
                public function hasNext():Boolean{
                        if (this.end == this.total) {
                                return false;
                        } else if (this.getTotalPage() <= 1) {
                                return false;
                        } else {
                                return true;
                        }
                }
        
                public function hastPrev():Boolean {
                        if (this.start == 0) {
                                return false;
                        } else {
                                return true;
                        }
                }
        
                public function PageConf(start:Number, limit:Number, total:Number) {/*  The constructor sets the start.  . And pages  . */
                        this.start = start;
                        this.limit = limit;
                        this.end = this.limit;
                        this.total = total;
                }
                
                public function pageItemClick(itemClick:ItemClickEvent, pageInfo:Label):void {
                                if(itemClick.index == 0){
                                        getFirst();
                                }else if(itemClick.index == 1){
                                        getPrev();
                                }else if(itemClick.index == 2){
                                        getNext();
                                }else if(itemClick.index == 3){
                                        getLast();
                                }else{
                                        return;
                                }
            }
            
            public function showPageInfo(pageInfo:Label):void {// Universal display Info page  .
                                var tempStart:Number = 0;
                                var tempEnd:Number = 0;
                                if(total != 0){// Troubleshoot display number 0 is the first problem  .App It is a start at 0  .
                                        tempStart = (start+1);
                                }
                                if(getCurrPage() == 0){
                                        tempEnd = Math.min(getEnd(), total);
                                }else{
                                        tempEnd = getEnd();
                                }
                                pageInfo.text = "["+tempStart+"-"+tempEnd+"/"+total+"]";
            }
            
            public function toString():String{
                return "start["+start+"]end["+
                end+"]total["+total+"]limit["+limit;
            }
        }
}


Then in a module ..

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" >
<mx:HBox width="100%">
    <mx:Label textAlign="right" paddingTop="4" width="90" height="22" fontWeight="bold" fontSize="12"></mx:Label>
        <mx:LinkBar>
                <mx:dataProvider>
                <mx:Array>
                    <mx:String> Home  </mx:String>
                    <mx:String> Previous  </mx:String>
                    <mx:String> The next page  </mx:String>
                    <mx:String> End  </mx:String>
                </mx:Array>
        </mx:dataProvider>
        </mx:LinkBar>
</mx:HBox>
</mx:Canvas>


In other documents which refer to this module.

The easiest page to do a page.

But also learned to manage sub-folders for the module.

Seriously do flex + spring + blazeDS + google app JDO paging. The total number for each inquiry.


Seriously do flex + spring + blazeDS + google app JDO paging. The total number for each inquiry.


Page as shown.

One method is called.

<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml"
  backgroundColor="#EEEEEE" width="100%" fontSize="12" initialize="initApp();" height="100%"
  xmlns:common="common.page.*">
  
<mx:RemoteObject destination="systemUserDAO">
        <mx:method name="list" result="listHandler(event)"/>
        <mx:method name="listSize" result="listSizeHandler(event)"/>
</mx:RemoteObject>
<mx:Script>
        <![CDATA[
                import mx.collections.ArrayCollection;
                import mx.events.ItemClickEvent;
                import mx.rpc.events.ResultEvent;
                import common.page.PageConf;
                import mx.controls.Alert;
                import mx.managers.PopUpManager;
                
                private var myPageConf:PageConf;
                // The initialization function  .
                private function initApp():void{
                        // Define a default load classes  .
                myPageConf = new PageConf(0,15,0);
                // The first default query data  .
                systemUserDAO.listSize();
                // To bind an event of universal paging Bar  .
                commonPageBar.pageLikBar.addEventListener(ItemClickEvent.ITEM_CLICK,
                        function(event:ItemClickEvent):void{// Anonymous functions  .
                                myPageConf.pageItemClick(event, commonPageBar.pageInfo);
                                systemUserDAO.listSize();
                });
                }
                // The list shows the data  .
                [Bindable]
        private var listData:ArrayCollection;
        // The total number of response processing query  .
                private function listSizeHandler(event:ResultEvent):void
                {
                        var pageSize:Number = event.result as Number;
                        myPageConf.total = pageSize;
                        systemUserDAO.list(myPageConf.getStart(), myPageConf.getEnd());
                        // The total number of records to display information.  .
                        myPageConf.showPageInfo(commonPageBar.pageInfo);
                }
                // Query data response processing  .
                private function listHandler(event:ResultEvent):void
                {
                         listData = event.result as ArrayCollection;
                }
        ]]>
</mx:Script>
        
<mx:VBox>
        <mx:DataGrid width="100%" height="386" 
                editable="false" dataProvider="{listData}">
            <mx:columns>
                <mx:DataGridColumn headerText="id" width="10" />
                <mx:DataGridColumn headerText=" Sign-in name  " dataField="loginName"/>
                <mx:DataGridColumn headerText=" Name  " dataField="name"/>
                <mx:DataGridColumn headerText=" Phone  " dataField="phone"/>
                <mx:DataGridColumn headerText="email" dataField="email"/>
                <mx:DataGridColumn headerText=" Creation time  " dataField="createDate"/>
            </mx:columns>
        </mx:DataGrid>
        <mx:HBox width="100%">
                <mx:Button label=" Add new  " click="addForm();"/>
                <mx:Button label=" Delete  "/>
                <mx:Spacer width="100"/>
        <common:PageBar/>
        </mx:HBox>
</mx:VBox>

</mx:Module>


There is a problem .. I use two remote method call.

The first query of total number of pages. Which then flip. And then query

Data. Each time to check the total. Write two methods. There is no good way to think of inquiry.

Background was found with a google app generic dao support above reflective. Borrow someone else's code under.

Query DAO generic class.

package com.freewebsys.dao.impl;

import java.lang.reflect.ParameterizedType;
import java.util.List;
import java.util.Map;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import org.springframework.orm.jdo.support.JdoDaoSupport;
import com.freewebsys.dao.IGenericDAO;
import com.freewebsys.jdo.BaseBean;
import com.freewebsys.jdo.SystemUser;

@SuppressWarnings("unchecked")
public abstract class GenericDAOImpl<T extends BaseBean> extends JdoDaoSupport
                implements IGenericDAO {

        private Class<T> entityClass;

        public GenericDAOImpl() {
                //  Classic through reflection to get class  .
                entityClass = (Class<T>) ((ParameterizedType) getClass()
                                .getGenericSuperclass()).getActualTypeArguments()[0];
        }

        @Override
        public boolean delete(BaseBean item) {
                // TODO Auto-generated method stub
                return false;
        }

        @Override
        public boolean save(BaseBean item) {
                PersistenceManager pm = getPersistenceManager();
                System.out.println(this.entityClass + " Call the Save method  .");
                try {
                        if (item.getId() == null) {
                                pm.makePersistent(item);
                        } else {
                                BaseBean itemOld = pm.getObjectById(item.getClass(), item
                                                .getId());
                                pm.makePersistent(itemOld);
                        }
                } catch (Exception e) {
                        e.printStackTrace();
                } finally {
                        pm.close();
                }
                return false;
        }

        @Override
        public T findById(long id) {
                return null;
        }

        @Override
        public List<T> findByProp(Map value) {
                return null;
        }

        @Override
        public List<T> list(long start, long end) {
                PersistenceManager pm = getPersistenceManager();
                try {
                        Query query = pm.newQuery(entityClass);
                        /**  Add the sort query .sort is sort fields  .dir Is the order or reverse order  . */
                        System.out.println("JDO pageList:[" + query.toString() + "]start:["
                                        + start + "]end:[" + end + "]");
                        query.setRange(start, end);
                        List<T> results = (List<T>) query.execute("Smith");
                        // for(int i = 0; i < results.size(); i ++){
                        // T t = results.get(i);
                        // System.out.println(t);
                        // }
                        /**  Set a start and end  . */
                        System.out.println("results size:[\t" + results.size());
                        return results;
                } catch (Exception e) {
                        e.printStackTrace();
                } finally {
                        pm.close();
                }
                return null;
        }

        @Override
        public long listSize() {
                PersistenceManager pm = getPersistenceManager();
                try {
                        long size = 0;
                        /**  Maximum number of query  . */
                        Query query = pm.newQuery("select count(id) from "
                                        + entityClass.getName());
                        /**  The total number of query  . */
                        // query = commonListQuery(query, null);

                        /**  Cast  int */
                        size = Long.parseLong(query.execute("Smith").toString());
                        //System.out.println("JDO pageSize:\t" + query.toString());
                        return size;
                } catch (Exception e) {
                        e.printStackTrace();
                } finally {
                        pm.close();
                }
                return 0;
        }
}


Also solved. In flip when inserting new data. Next page update.

Relatively satisfied with the paging.

Annex is the code.

http://myflexeye.appspot.com

Deployed to the google server. Can run.

Annex engineering. BlazeDS and app spring without the jar file.
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Seriously do flex + spring + blazeDS + google app JDO paging. The total number for each inquiry.

  • Manual configuration in UBUNTU under ruby on rails environment

    Careless mistake for the day before yesterday, the sources, the results after 810 error after the upgrade, the loss of response button. On google found a lot of trouble really, lucky point modification under the / etc/X11/xorg.conf to restore both, b ...

  • Ruby Rails system calls the use of Ping

    Want to use call system commands under RoR, the general exec and system and the syscall Want to use in Rails, the call ping command The most common are ruby support Ping usage is as follows: Ping contains routines to test for the reachability of remote ho

  • IE7 under, Rails link_to questions generated failure Confirm

    link_to property has a method often used with: confirm delete property to do the confirmation link. In fact, in the onclick link to create a temporary form, submit a request, and finally return false, so the link itself will not be triggered. However ...

  • Play flash page 3 (javascript script swfobject.js2)

    this.setAttribute ( "swf", this.xiSWFPath);) _19 = "<object \" "+ this.getAttribute (" id ") +" \ "classid = \" clsid: D27CDB6E-AE6D-11cf-96B8-444553540000 \ "width = \" "+ this.getAttrib

  • Rails source code analysis (4): Request / Response

    1) Rails defines two abstract class: AbstractRequest and AbstractResponse code is not posted, first take a look at Response. 2) is mainly responsible for the specific ctgi_process.rb main interface is responsible for implementation methods of impleme ...

  • What is the JPA

    Same, JDO, also started compatible JPA. At the field of ORM, it seems that JPA is a benevolent government, is the normative specification. At the support of major manufacturers, JPA use became widespread. 2 Spring Spring + Hibernate often referred to as t

  • Use Ext JS to read the JsonReader complex object json

    Today was how to resolve the following complex json object to the difficult living over a long time .. did not find documentation how to read JsonReader Ways json object (possibly also because of their limited level of E the text did not correctly underst

  • NoClassDefFoundError: javax / servlet / Servlet

    In the project in order to achieve a listener in web.xml set up a listener, did start in Tomcat actually occurred after java.lang.NoClassDefFoundError: javax / servlet / ServletContextListener this anomaly google and found the reasons for the lack of serv

  • Dynamic loading JS script four kinds of methods

    To achieve dynamic loading JS script has four kinds of methods: 1, direct document.write <script language="javascript"> document.write ( "<script src='test.js'> <\ / script>"); </ script> 2, dynamic scri

  • Struts2 + hibernate + spring problem user log in

    dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries