gpt4 book ai didi

jsf - 如何从

转载 作者:行者123 更新时间:2023-12-04 09:32:51 26 4
gpt4 key购买 nike

在这段代码中,

<p:galleria value="#{Bean.images}" var="image" panelWidth="500" panelHeight="313" showCaption="true"
<p:graphicImage value="/images/galleria/#{image}" alt="Image Description for #{image}" title="#{image}"/
</p:galleria>

你如何获得 selectedImage ?如表达在
<p:carousel id="carousel" value="#{tableBean.carsSmall}" var="car" itemStyleClass="carItem" headerText="Cars"> 
<p:graphicImage id="image" value="/images/cars/#{car.manufacturer}.jpg"/>

<h:panelGrid columns="2" style="width:100%" cellpadding="5">
<h:outputText value="Model: " /><h:outputText id="model" value="#{car.model}" />
</h:panelGrid>

<p:commandLink id="view" update=":form:carDetail" oncomplete="carDialog.show()" title="View Detail">
<h:outputText styleClass="ui-icon ui-icon-search" style="margin:0 auto;" />
<f:setPropertyActionListener value="#{car}"
target="#{tableBean.selectedCar}" />
</p:commandLink>
</p:carousel>

最佳答案

假设您在每个当前显示的图片上都有一个详细信息按钮
(将 alt 属性设置为图像文件名)

<p:galleria value="#{Bean.images}" var="image">
<p:graphicImage value="/images/galleria/#{image}"/>

<f:facet name="content">
<p:graphicImage value="/images/galleria/#{image}" alt="#{image}" />
<span style="position:absolute;right:0;top:0;">
<p:commandButton styleClass="ui-icon ui-icon-search" onclick="jsCallRemote(this);" />
</span>
</f:facet>
</p:galleria>

搜索按钮可以调用一个 js 函数,通过按钮本身作为查找当前图像文件名的提示,然后调用远程命令将文件名作为请求参数传递给它:
<script>
function jsCallRemote(btn) {
var imageFileName = btn.parentNode.parentNode.getElementsByTagName('img')[0].alt;
selectImage([{name:'imageFileName', value:imageFileName}]);
}
</script>

<p:remoteCommand name="selectImage" actionListener="#{tableBean.selectImage}" />

而 bean 的方法通过请求参数 imageFileName 进行实际选择:
public void selectImage() {
String fileName = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("imageFileName");
// find image by filename...
}

关于jsf - 如何从 <p :galleria 获取所选图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16948731/

26 4 0

Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com