【发布时间】:2016-10-18 15:22:36
【问题描述】:
我将带有 JS 的变量发送到输入文本。然后当值被设置时,我点击一个 p:commandButton 来调用一个使用该值的方法,但传递的值是空白的......虽然 js 将值发送到输入并且我看到它......它需要它作为空白。如果我自己输入值,它会在方法中读取它......否则它不会......任何想法? 这是我尽可能多地恢复的代码(有点长):
XHTML:
<!-- Modal -->
<div class="modal fade" id="myModalId" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-warning">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel"><b>#{msg.html32}</b></h4>
</div>
<div class="modal-body">
<center style="font-size: 14px">#{msg.html31}</center>
</div>
<div class="modal-footer">
<p:commandLink action="#{bd.setId(dotcalpro.id)}" styleClass="btn btn-md btn-info" value="#{msg.htmlborrar}" immediate="true" update="tbResult, growl" accesskey="r" onclick="modalIdhide()"/>
<p:spacer height="5"/>
<p:commandLink styleClass="btn btn-md btn-info" value="#{msg.html48}" immediate="true" update="tbResult, growl" onclick="modalIdhide()"/>
</div>
</div>
</div>
</div>
<p:column width="60">
<f:facet name="header">#{msg.dotcalprotbver}</f:facet>
<center>
<button type="button" class="btn btn-warning btn-xs"
onclick="detalle('#{tb.zid}'); modalIdshow();" >
<i class="fa fa-search fa-2x"></i>
</button>
</center>
</p:column>
JS:
function detalle(vT0){
document.getElementById("formdotcalpro:id").value= rTrim(vT0);
updateInput('formdotcalpro:id', '#F2F2F2')
//alert(document.getElementById("formdotcalpro:id").value);
var x = document.getElementById("formdotcalpro:id").value;
alert("valor: " + x)
}
//Modal id show
function modalIdshow(){
$("#myModalId").modal();
}
//Modal id hide
function modalIdhide(){
$("#myModalId").modal('hide');
}
豆子:
/**
* Setea tipo de valor de la meta para busqueda
* @param next
*/
public void setId(String id){
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("id", id);
System.out.println("valor : " + id);
}
我再说一遍,以防我尽可能多地恢复代码。
【问题讨论】:
标签: javascript html jsf primefaces