2016-10-18 5 views
-1

私はJSで変数を入力テキストに送信しています。値が設定されたら、その値を使用するメソッドを呼び出すにはap:commandButtonをクリックしますが、渡される値は空白です... jsは値を入力に送信しましたが、空白として私が値を自分で入力すると、メソッドでそれを読んでいます... otherwhiseそれは...任意のアイデアですか? は、ここに私のコードは同じくらいだ私は(それは一種の長いのです)、それを得ることができるように再開:JavaScriptとPrimefaceで値が正しく設定されていません

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">&times;</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); 
} 

私はコードをポーズできるだけ再開した場合に備えて、もう一度言います。

答えて

0

私はsesion変数で何らかの解決策を見つけました...それはうまくいきましたが、確かにそれがリグなものかどうかはわかりません。

はちょうど私のBeanクラスでこれを追加しました:あなたは時間があれば

/** 
* Setea tipo de valor de la meta para busqueda 
* @param next 
*/ 
public void setId(String id){ 
    HttpServletRequest rq = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); 
    String idval = rq.getParameter("formdotcalpro:id"); 
    FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("id", idval); 
    //System.out.println("valor : " + idval); 
} 

私はまだこの問題に対する別の視点を歓迎します。

関連する問題