2011-04-03 72 views
0

我有一個要求,在點擊圖像時我需要在模態面板上顯示相同圖像的較大尺寸。如何訪問在模態面板中傳遞的參數

爲此,我所做的就是將圖像位置作爲f:param傳遞給模態面板,然後在圖像標記中使用傳遞的參數。

但不知何故,我無法獲得我傳遞參數的值。

下面是代碼:

這是我如何激活modalPanel我如何傳遞參數usingf:PARAM

<h:graphicImage value="../images/DSCN0965.JPG" height="50" width="50" styleClass="iconClass"> 

    <rich:componentControl for="imagePanel" operation="show" event="onclick"> 

     <f:param value="../images/DSCN0965.JPG" name="imagePath"/> 

    </rich:componentControl> 

</h:graphicImage> 

這是模式面板代碼,我如何試圖讓F:參數值在這裏...

<rich:modalPanel id="imagePanel" width="600" height="600"> 

     <f:facet name="header"> 

      <h:panelGroup> 

       <h:outputText value="Image"></h:outputText> 

      </h:panelGroup> 

     </f:facet> 

     <f:facet name="controls"> 

      <h:panelGroup> 

       <h:graphicImage value="../images/closeIcon.GIF" styleClass="iconClass" id="closeImageLink"/> 

       <rich:componentControl for="imagePanel" attachTo="closeImageLink" operation="hide" event="onclick"/> 

      </h:panelGroup> 

     </f:facet> 

     <h:outputLabel value="#{imagePath}"/> 

     <h:graphicImage value="{imagePath}" height="400" width="500" styleClass="iconClass"/> 

    </rich:modalPanel> 

你能告訴我如何訪問傳遞的參數值嗎?

問候,

薩蒂亞

回答

0

在這裏,你不需要設置參數值的方式,用於顯示較大的圖像,而不是本可以只用javascript很容易地完成。

給模型面板的圖像元素id說「largeImage」,並在頁面中使用下面的腳本更小的圖像

onclick = "document.getElementById('largeImage').src = this.src;"

以下腳本打開面板。

要傳遞參數值,您需要按照here所述將它綁定到JSF支持bean對象。

+0

那是對的,我已經完成了它使用JavaScript。我不必爲此使用f:param – Satya 2011-04-04 15:29:15