0 Replies Latest reply on Dec 3, 2009 8:47 PM by Dan Acuff

    How to display SELECTED first in Select List?

    Dan Acuff Newbie
      I have some front end xhtml but I need the selectItems to display the default(selected) value first:
      <h:selectOneMenu id="billing01_payment"
                              value="#{customerSession.selectedPaymentMethod}">
                              <s:convertEntity />
                             
                             
                              <s:selectItems id="billing01_payments" var="_var"
                                      label="#{_var.formattedAddress}" noSelectionLabel="New Card"
                                      value="#{customerSession.payments}" />
                             
                             
                              <a:support event="onchange" reRender="paymentInputAjax"
                                      action="#{customerSession.copyPayment}" ajaxSingle="false" />
      </h:selectOneMenu>

      In the customerPaymentMethod class there are some queries and I was wondering how I would order by default so that the default payment method displays first in a Select List:

      @Entity
      @Table(name = "CustomerPaymentMethod")
      @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
      @NamedQueries( {
                      @NamedQuery(name = "CustomerPaymentMethod.getDefault", query = "select i from CustomerPaymentMethod i where i.customer.id=:customerId and i.defaultFlag=true"),
                      @NamedQuery(name = "CustomerPaymentMethod.getCustomerPaymentMethods", query = "select i from CustomerPaymentMethod i where i.customer.id=:customerId"),
                      @NamedQuery(name = "CustomerPaymentMethod.updateDefault", query = "update CustomerPaymentMethod c set c.defaultFlag=true where c.id=:id"),
                      @NamedQuery(name = "CustomerPaymentMethod.updateNonDefault", query = "update CustomerPaymentMethod c set c.defaultFlag=false where c.customer.id=:customerId and c.id<>:id") })


      I am new to Java and Seam any help would be very appreciated.