javascript - JSF selectOneRadio item with image, how to set the radio button CHECKED -
I want to get the following UI in JSF. [Radio button] [image] [label] <
[radio button] [image] [label]
[radio button] [image] [ Label] and so on ...
The UI looks good after applying the following code, but when I click on a radio button, the selection is not shown in the UI (radio is not checked ), Although the Bean class is updated by value-added events. How can I choose a radio check?
JSF Code:
& lt ;! - Payment options - & gt; & Lt; Ui: Repetition value = "# {shoppingCartBean.paymentMethods}" var = "m" & gt; & Lt ;! - radio button - & gt; & Lt; div style = "float: left;" & Gt; & Lt; Ice: selectOneRadio value = "# {shoppingCartBean.selectedPaymentMethod}" layout = "page direction" partially submit = "true" change valueEilizer = "# {shoppingCartHandler.valueChanged}" & gt; & Lt; F: select item item label = "item" value = "# {m}" /> & lt; / Ice: selectOneRadio & gt; & Lt; / Div & gt; & Lt ;! - Card image - & gt; & Lt; div style = "float: left;" & Gt; & Lt; Ice: graphic image value = "# {layoutbinnings.upnetspath} / # {m} .png" /> & Lt; / Div & gt; & Lt ;! - Payment method description or label - & gt; & Lt; Div style = "padding: 10px" & gt; & Lt; Ice: outputtext value = "# {bundle message. Message [m]}" /> & Lt; / Div & gt; & Lt; Div style = "clear: both;" & Gt; & Lt; / Div & gt; & Lt; / ui: Repeat & gt; & Lt ;! - Payment options end - & gt; and method in the Bean category:
public list & lt; String & gt; GetPaymentMethods () {List & lt; String & gt; Payment methods = new arreelist & lt; String & gt; (); PaymentMethods.add ("crditcard"); PaymentMethods.add ("directbanking"); PaymentMethods.add ("paypal"); Return payment procedures; } Selective payment method to receive public string () {Return it. Selected payment method; } Public Zero Set selected payment (string selected payment method) {this.selectedPaymented Method = Selected PaymentMethod; } and change the value in the handler class:
changed the public zero value (ValueChangeEvent event) {string value = zero; If (event.getSource () example HtmlSelectOneRadio) {value = ((string) event.getNewValue ()); } If (value! = Zero) {this.shoppingCartBean.setSelectedPaymentMethod (value); }} "
Actually the value of the radio button" # # ShoppingCartBen.Selected Payment Method '' Overwrite several times with empty or wrong strings found. Therefore, always show incorrect or no selection in the radio button.
I had followed the workplace to avoid wrong setting of 'selected payment method' in Bean class. And it was ensured that the 'selected payment' method is updated only in the handler class by 'value added' method.
Changes made in the value changed event of the handler class:
changed the public zero value (ValueChangeEvent event) {string value = zero; If (event.getSource () example HtmlSelectOneRadio) {value = ((string) event.getNewValue ()); } If (value! = Null) {this.shoppingCartBean.SsetPaymentMethod (value); }} and amendment to bean category:
public zero set selected payment (string selected payment method) {// nothing, this method is empty Skip} Public Zero Set PaymentMath (String Payment Method) {this.selectedPaymented Method = paymentMethod; } Now the 'Selected Payments' always gives selected radio items, so the correct radio item is checked.
Comments
Post a Comment