使用jsf中所选项目的ID

时间:2016-05-09 20:39:12

标签: jsf primefaces datatable selection

我想使用下面列表中所选项目的ID在其他功能中使用它,我该怎么做呢,我正在使用JSF;

我已经多次尝试但是徒劳无功!!请帮忙

this picture may help you to understand my goal

这是我在jsf中的代码:

<p:panelGrid columns="2" style="width:60%  ; padding-left:25%"
    layout="grid">
    <p:dataTable var="convert"
        value="#{convertirDeviseCtr.listeDevise}" style="width:70%"
        id="convertir">
        <f:facet name="header">Liste des devises</f:facet>


        <p:column selectionMode="single">
            <h:outputText value="&#160;" />
            <h:outputText value="&#160;" />
            <p:graphicImage value="/images/flags/#{convert.libSiglDev}.png"
                id="img" style="width:20px ; height:20px" />
            <h:outputText value="&#160;" />
            <h:outputText value="&#160;" />
            <h:outputText value="#{convert.libDevDev}" />
        </p:column>
    </p:dataTable>

    <p:panel style="padding-top:40%">
        <br />
        <h:outputText value="Saisir montant :" />
        <h:outputText value="&#160;" />
        <p:keyboard id="image" value="#{keyboardView.value8}"
            showMode="button" buttonImageOnly="true"
            buttonImage="/images/icons/keyboardpencil.png" keypadOnly="true"
            style="width:150px ; height:20px" />
        <br />
        <br />
        <p:selectOneButton value="" style="margin-left:35%">
            <f:selectItem itemLabel="Achat" itemValue="A" />
            <f:selectItem itemLabel="Vente" itemValue="V" />
        </p:selectOneButton>
        <br />
        <br />
        <p:commandButton value="Convertir" icon="ui-icon-refresh"
            style="margin-left:40%"></p:commandButton>
        <br />
        <br />
        <p:outputLabel>Resultat :</p:outputLabel>
        <p:inputText value=""></p:inputText>
    </p:panel>
</p:panelGrid>

提前感谢;

1 个答案:

答案 0 :(得分:1)

您必须使用(-main)的{​​{1}}属性。 <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /> </head> <body> <header class="desktop"> </header> <div id="st-container" class="st-container"> <div class="st-pusher"> <div class="st-content"> <div class="st-content-inner"> <div class="logo-mobile"> </div> <section class="map-sections"> <div style="position: absolute; z-index: 1000; width: 100%; margin-top: 30px;"> <div class="row"> <div class="large-12 columns"> <div class="filter clearfix"> <input type="text" id="search-field" placeholder="Search place"> <span>eller...</span> <a href="#" id="search-button" class="btn pink geolocate" onclick="showMap('true');">Search near you</a> </div> </div> </div> </div> <div id="google_canvas"></div> <script src="http://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true"></script> <script type="text/javascript"> function showMap(userPos) { if (!!navigator.geolocation) { var map; if (userPos == 'true') { var mapOptions = { zoom: 12, enableHighAccuracy: true, mapTypeControl: false, streetViewControl: false, mapTypeId: google.maps.MapTypeId.ROADMAP }; } else { var mapOptions = { zoom: 5, enableHighAccuracy: false, mapTypeControl: false, streetViewControl: false, mapTypeId: google.maps.MapTypeId.ROADMAP }; } map = new google.maps.Map(document.getElementById('google_canvas'), mapOptions); navigator.geolocation.getCurrentPosition(function (position) { var geolocate = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); var sectionList = [ ['Stockholm', 59.327, 18.067], ['Göteborg', 57.70889, 11.97348] ]; var mapPinUser = '/dist/img/map-pin-user.png'; var mapPinSection = '/dist/img/map-pin-section.png'; // User's position var marker = new google.maps.Marker({ position: geolocate, map: map, icon: mapPinUser, title: "ok" }); for (var i = 0; i < sectionList.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(sectionList[i][1], sectionList[i][2]), map: map, icon: mapPinSection, id: i, animation: google.maps.Animation.DROP, title: sectionList[i][0] }); } if (userPos == 'true') { map.panTo(geolocate); } else { map.setCenter({ lat: 61.58549, lng: 15.02930 }); } }); } else { document.getElementById('google_canvas').innerHTML = 'No Geolocation Support.'; } } showMap('false'); </script> <style> #google_canvas { height: 65vh; } </style> </section> </div> </div> </div> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script> </body> </html> 属性的值必须是支持bean的属性,其中将存储所选值。例如:

selection

有关<p:dataTable>标记和不同类型的选择模式的更多信息:

http://www.primefaces.org/showcase/ui/data/datatable/selection.xhtml