a4j:带大型mp3文件的mediaOutput

时间:2012-06-03 21:32:39

标签: java ajax richfaces seam

不确定我做错了什么。我补充说:

<h:form id="media">
<a4j:mediaOutput id="aud"  element="object" cacheable="false" session="true"
    title="canYouSeeMe"
    width="300"
        createContent="#{mediaPlay.play}"
        value="#{sdh:storeDataAndGetKey(mediaPlay.selectedFileData)}"
        mimeType="audio/x-mpeg" />
</h:form>

当我第一次在Firefox中打开页面时,我收到一条消息,说我需要安装QuickTime插件。但没有别的。我看不到在FF或IE中播放音频的链接或方式。我从这里的教程得到的递归storeDataAndGetKey方法: https://community.jboss.org/wiki/A4jmediaOutputAndLargeObjectsAsValue 对于大型物体。

private static DataHolder getGraphDataHolder() {
        FacesContext fc = FacesContext.getCurrentInstance();

        ExternalContext externalContext = fc.getExternalContext();
        Map<String, Object> sessionMap = externalContext.getSessionMap();
        Object session = externalContext.getSession(true);
        DataHolder holder;
        synchronized (session) {
            holder = (DataHolder) sessionMap.get(DATA_HOLDER_ATTRIBUTE_NAME);
            if(holder == null){
                holder = new DataHolder();
                sessionMap.put(DATA_HOLDER_ATTRIBUTE_NAME, holder);
            }
        }
        return holder;
    }

    public static Object getDataByKey(Object key) {
        DataHolder holder = getGraphDataHolder();

        return holder.getDataByKey(key);
    }

mediaPlay.play:

public synchronized void play (OutputStream stream, Object object) throws IOException {
     Object restoredData = SessionDataHelper.getDataByKey(object);
     byte[] soundData = ((Data) restoredData).getFileData();
     stream.write(soundData);
}

我可以在页面源中看到该组件,但在呈现的页面中看不到。我甚至不确定我应该看到什么。

编辑添加原始HTML 页面加载后

<form id="j_id18:media" name="j_id18:media" method="post" action="/home.seam" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_id18:media" value="j_id18:media" />
<object id="j_id18:media:aud" data="/a4j/s/3_3_1.GAorg.ajax4jsf.resource.UserResource/n/s/-1007594989/DATA/eAFlUs9rE0EUfl0stv4Aa6ziQai1KIiZmGS3UWpBUFEhsWJsQT297L4ks8zurDOz6WrRmxcFL169edWL!gVeC176NwgiIoggXp2dFKV1DgNv-N73fe978!Y7TGoFZ6UaMIyx8GPdZ4q0zFVIbFWTurNdLKwqfhUNQnkqwTcP9rThYKgIDV2RqaHUGDjcjnGENYHpoLbSiyk0S23YS0XGLedDeAoTbZhKZMT7nKLtenKEIidXFJn1crqkKFgfQ9IslEkmU8vNusYK3ZAiItXFEal7mx-WX73-1PHAa8N0KFDrW5jQTg9do3g6sB72adsTOQ4DR8cuuax1SXEU!DH2BC0VWSl!xkoynafOgCCjGQl2FwcdMkMZXSsyO4nmMnU5AEwcACgUHB-bttDduPe1zReff!svPYer!MX9Y3rz7Hn35!2tSyWidHCyXEbck9pJ7-a7mWSi9-PYr!0fZzqldhnc1PoszJzaSCjieFvgI5bZ6wlArqDywA3LypXYDF0c77bWvnw9sXHdCdo5PANHSl-MS7aSmyw3FkiYGDjknl3veJ1ZVqwvgl8byoRYMTSJmLvcWDzXDOZ2!ITl-f!czNt4DSy0ggZSE!1qENYvVP3zF6mKjSCq9lutRp2CZt0Pmn8A3l!elQ__" title="canYouSeeMe" width="300"></object><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id2" />

</form>

这是Seam 2.2,RichFaces 3.3.3。在JBoss 5.1上运行

0 个答案:

没有答案