2010-03-02 90 views
0
  • 如何從blazeds客戶端訪問jsf託管bean(比如icefaces)?
  • 是否有可能共享相同的會話信息? (對於例如,如果我有一個JSF/ICEfaces的組件和SWF客戶端頁面 - 他們能使用同一個會話?)

回答

0

首先你必須在你自己的工廠的FlexFactory:
http://livedocs.adobe.com/blazeds/1/blazeds_devguide/factory_2.html

我改變SpringFactory一點點,所以你可以訪問給定的bean的當前實例:

public class BeanFactory implements FlexFactory { 

private static final String SOURCE = "source"; 

public void initialize(String id, ConfigMap configMap) {} 

public FactoryInstance createFactoryInstance(String id, ConfigMap properties) { 
    BeanFactoryInstance instance = new BeanFactoryInstance(this, id, properties); 
    instance.setSource(properties.getPropertyAsString(SOURCE, instance.getId())); 
    return instance; 
} 

public Object lookup(FactoryInstance inst) { 
    BeanFactoryInstance factoryInstance = (BeanFactoryInstance) inst; 
    return factoryInstance.lookup(); 
} 

static class BeanFactoryInstance extends FactoryInstance { 
    BeanFactoryInstance(BeanFactory factory, String id, ConfigMap properties) { 
     super(factory, id, properties); 
    } 

    public String toString() { 
     return "BeanFactory instance for id=" + getId() + " source=" + getSource() + " scope=" + getScope(); 
    } 

    public Object lookup() { 
     HttpServletRequest hsr = FlexContext.getHttpRequest(); 
     String beanName = getSource(); 

     try 
     { 
      Object o = hsr.getSession().getAttribute(beanName); 
      return o; 
     } 
     catch (Exception e) 
     { 
      ServiceException se = new ServiceException(); 
      String msg = "Java Bean '" + beanName + "' does not exist."; 
      se.setMessage(msg); 
      se.setRootCause(e); 
      se.setDetails(msg); 
      se.setCode("Server.Processing"); 
      throw se; 
     } 
    } 
}} 
在服務-config.xml中

(WEB-INF/flex文件夾),你必須註冊本廠:

<factories> 
    <factory id="beanFactory" class="packageName.BeanFactory"/> 
</factories> 

,那麼你必須在遠程-config.xml中這樣你的目的地註冊工廠:

<destination id="remoteService"> 
     <properties> 
      <factory>beanFactory</factory> 
      <source>beanName</source> 
      <scope>session</scope> 
     </properties> 
</destination> 

所以這是什麼做的BeanFactory:
當你想從柔性每個遠程訪問到java或jee-應用程序,您在flex中聲明一個remoteobject,並在remoting-config.xml中配置目標「remoteService」。當您通過調用服務器端方法從flex訪問java時,beanfactory會通過在FlexContext上獲取請求來查看您在remoting-config.xml中聲明的bean的當前實例:
HttpServletRequest hsr = FlexContext .getHttpRequest();

現在你得到了會議,並與beanName實例調用
hsr.getSession()的getAttribute(beanName)

,它只能在應用程序和會話bean工作且僅當JSF前的實例豆Bean工廠要訪問的豆...
當你想整合與ICEfaces的一個swf文件,你應該取冰
:outputMedia-標籤的設置播放器屬性「閃」

如果你工作用eclipse來開發你的jee應用程序,然後你整合tomca噸日食可以設置服務器的根文件夾在Flex項目到tomcat文件夾(的Flex Builder)的性質:
alt text (對不起不是使這個看起來不錯的時間;))

現在你可以在eclipse中直接啓動tomcat服務器,你也可以在flex和java上進行調試:)

希望這有助於!