论坛首页 编程语言技术论坛

flex通过java连数据库

浏览 4071 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-08-02  
本人最近由于工作项目需要改造http://www.flex2.org/node/85中的效果一,,其源代码为:
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2006 Adobe Systems Incorporated
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
-->
<Application xmlns="http://www.adobe.com/2006/mxml" xmlns:local="*" height="100%" width="100%" layout="absolute" viewSourceURL="download/index.html">

<Binding source="sel.value" destination="shelf.selectedIndex" />
<Binding destination="sel.value" source="shelf.selectedIndex" />

<Binding source="angle.value" destination="shelf.angle" />
<Binding source="pop.value" destination="shelf.popout" />
<Array id="dataSet">
  <String>img/photos400/01000.jpg</String>  
  <String>img/photos400/01001.jpg</String>  
  <String>img/photos400/01002.jpg</String>  
  <String>img/photos400/01003.jpg</String>  
  <String>img/photos400/01004.jpg</String>  
  <String>img/photos400/01005.jpg</String>  
  <String>img/photos400/01006.jpg</String>  
  <String>img/photos400/01007.jpg</String>  
  <String>img/photos400/01008.jpg</String>  
  <String>img/photos400/01009.jpg</String>  
  <String>img/photos400/01010.jpg</String>  
  <String>img/photos400/01012.jpg</String>  
  <String>img/photos400/01013.jpg</String>  
  <String>img/photos400/01014.jpg</String>  
  <String>img/photos400/01015.jpg</String>  
  <String>img/photos400/01016.jpg</String>  
  <String>img/photos400/01017.jpg</String>  
  <String>img/photos400/01018.jpg</String>  
  <String>img/photos400/01019.jpg</String>    
</Array>

<local:DisplayShelf id="shelf"  horiz verticalCenter="0"
  borderThickness="10" borderColor="#FFFFFF" dataProvider="{dataSet}"  enableHistory="false" width="100%"/>
<VBox horiz bottom="10"
  horiz verticalAlign="middle" >  
  <HBox>
   <Label text="Angle:" />
   <HSlider liveDragging="true" id="angle" minimum="5" value="35" maximum="90" snapInterval=".1" width="400" />
  </HBox>
  <HBox>
   <Label text="Selection:" />
   <HSlider liveDragging="true" id="sel" minimum="0" value="0" maximum="{shelf.dataProvider.length}" snapInterval="1" width="400" />
  </HBox>
  <HBox>
   <Label text="pop:" />
   <HSlider liveDragging="true" id="pop" minimum="0" value=".43" maximum="1" snapInterval=".01" width="400" />
  </HBox>
</VBox>
</Application>


现在我想把上面的字符串改造成从数据库中读取,我改造的程序的部分代码如下:
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns:mx="http://www.adobe.com/2006/mxml" f
xmlns="http://www.adobe.com/2006/mxml"
xmlns:local="*" height="100%" width="100%"
layout="absolute"
viewSourceURL="index.html"
creati
>

<mx:Script>
   <![CDATA[
  import mx.controls.Alert;
  import mx.utils.ArrayUtil;
        import mx.collections.ArrayCollection;
      
        //保存返回图片事件集合的内容
        [Bindable]
       public var imgList:Array;
      
       //初始化程序,调用图片对象的返回图片集,送将结果送给flex事件集
        public function initApp():void
            {
              src.getAllImg();
            }
   ]]>
    </mx:Script>
    <Binding source="sel.value" destination="shelf.selectedIndex" />
<Binding destination="sel.value" source="shelf.selectedIndex" />

<Binding source="angle.value" destination="shelf.angle" />
<Binding source="pop.value" destination="shelf.popout" />

<!--本地化远程返回图片的对象-->
   <mx:RemoteObject id="src"
destination="imageDB"
result="imgList=ArrayUtil.toArray(event.result)"
fault="Alert.show(event.fault.faultString,'Error')"
/>

<local:DisplayShelf id="shelf" 
  dataProvider="{imgList}"
  horiz verticalCenter="0"
  borderThickness="5" borderColor="#FFFFFF"
  enableHistory="false" width="100%"
  />
..... ...
    但生成的代码后,图片显示了,但无论如何调整那个滑条都没效果!!我研究了都快两周了,效果还是不知道怎么加上去,哪位高手或者好心人帮我看下,告诉我为什么啊

相关的javabean和pojo代码为:



//ImageInfo.java

package cn.lx.image;

import java.io.Serializable;

public class ImageInfo implements Serializable { /** * */

       private static final long serialVersionUID = 1L;

       private int id;

       private String advername;

       private String adverpic;

      private String adverkey;

       private String advernumber;

       private int intstatu; private String intcatalog;

        private String area; private int istop;

        public String getAdverkey()

              return adverkey; }

       public void setAdverkey(String adverkey)

            this.adverkey = adverkey; }



.......................................

            //其它的的get set方法 }



//DataServiceImpl.java

      

  package cn.lx.image;

   import java.sql.*;

   import java.util.ArrayList;

   public class DataServiceImpl {

   // 查询图片,并返回图片记录

          public ImageInfo[] getImages() {

                  ArrayList imageList = new ArrayList();

                  String sqlText = "select top 10 id,advername,adverpic,adverkey,advernumber,intstatu,intcatalog,are                a,istop from adver_active";

                  ResultSet rs = executeQuery(sqlText);

                 try {

                         while (rs.next()) {

                                  ImageInfo imageinfo = new ImageInfo();

                                    imageinfo.setId(rs.getInt("id"));

                                   imageinfo.setAdvername(rs.getString("advername"));

                                  imageinfo.setAdverpic("http://192.168.18.99/"+"ad_pic/"+rs.getString("adverpic"));

                                  imageinfo.setAdverkey(rs.getString("adverkey")); imageinfo.setAdvernumber(rs.getString("advernumber"));

                                   imageinfo.setIntstatu(rs.getInt("intstatu")); imageinfo.setIntcatalog(rs.getString("intcatalog"));

                                  imageinfo.setArea(rs.getString("area")); imageinfo.setIstop(rs.getInt("istop")); imageList.add(imageinfo); } ImageInfo[] images = new ImageInfo[imageList.size()];

                         for (int i = 0; i < imageList.size(); i++) {

                                  images = (ImageInfo) imageList.get(i); }

                                       return images; } catch (SQLException e) { e.printStackTrace(); return null; } }



public Object[] getAllImg(){

return init().toArray(); }



private ArrayList init() {

ArrayList list = new ArrayList();

ImageInfo[] images=getImages();

for(int i=0;i.getAdverpic());

return list;

} }
论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics