1 Reply Latest reply on May 8, 2009 6:04 PM by clerum

    Entity Search and Select

    clerum

      I'm having a little bit of issue fitting the widgets together on this problem.


      I have an Entity(TelephoneNumber) which I'm creating and I need associate 3 other existing entites on the creation page.


      What I have so far is. Below. However I'm getting an


      22:48:55,353 WARN  [lifecycle] For input string: "BLNGMT - Billings, MT"
      java.lang.NumberFormatException: For input string: "BLNGMT - Billings, MT"


      It's passing the value of the suggestionBox rather than the entity. What is the correct way to do this? Can anyone post some sample code as I think this must be pretty common.


      <s:decorate template="/layout/edit.xhtml">
           <ui:define name="label">Site</ui:define>
           <h:inputText value="#{telephoneNumber.site}" id="site" size="75" required="false" label="#{telephoneNumber.site.name}">
                <s:convertEntity />
           </h:inputText>     
                <rich:suggestionbox for="site" suggestionAction="#{siteUtil.searchSites}"  var="_site" minChars="2" id="suggestion" width="500" selfRendered="true">
                   <h:column>
                     <h:outputText value="#{_site.name} - #{_site.alias}" />
                </h:column>
                </rich:suggestionbox> 
      </s:decorate>
      
      



      @Entity
      @Name("telephoneNumber")
      @Table(name="telephone_number")
      public class TelephoneNumber implements Serializable {
           
           private static final long serialVersionUID = 1L;
           
           private String number;
           private Date date_created;
           private Date date_modified;
           private boolean e911;
           private TNType type;
           private TNStatus status;
           private String cnam;
           private String forward;
           private Site site;
           private RateCenter rateCenter;
           private VoiceGroup voiceGroup;
           
           @Id
           public String getNumber() {
                return number;
           }
           public void setNumber(String number) {
                this.number = number;
           }
           
           @NotNull
           public Date getDate_created() {
                return date_created;
           }
           public void setDate_created(Date date_created) {
                this.date_created = date_created;
           }
           
           @Version
           public Date getDate_modified() {
                return date_modified;
           }
           public void setDate_modified(Date date_modified) {
                this.date_modified = date_modified;
           }
           
           @NotNull
           public boolean isE911() {
                return e911;
           }
           public void setE911(boolean e911) {
                this.e911 = e911;
           }
           public TNType getType() {
                return type;
           }
           public void setType(TNType type) {
                this.type = type;
           }
           public TNStatus getStatus() {
                return status;
           }
           public void setStatus(TNStatus status) {
                this.status = status;
           }
           
           @Length(max=15)
           public String getCnam() {
                return cnam;
           }
           public void setCnam(String cnam) {
                this.cnam = cnam;
           }
           public String getForward() {
                return forward;
           }
           public void setForward(String forward) {
                this.forward = forward;
           }
           
           @ManyToOne
           @JoinColumn(name = "site_id", nullable = true)
           public void setSite(Site site) {
                this.site = site;
           }
           public Site getSite() {
                return site;
           }
           @ManyToOne
           @JoinColumn(name = "rate_center_id", nullable = true)
           public RateCenter getRateCenter() {
                return rateCenter;
           }
           public void setRateCenter(RateCenter rateCenter) {
                this.rateCenter = rateCenter;
           }
           
           @ManyToOne
           @JoinColumn(name = "voice_group_id", nullable = true)
           public VoiceGroup getVoiceGroup() {
                return voiceGroup;
           }
           public void setVoiceGroup(VoiceGroup voiceGroup) {
                this.voiceGroup = voiceGroup;
           }     
      }
      

        • 1. Re: Entity Search and Select
          clerum

          OK-


          This is what I ended up going with.


          <s:decorate template="/layout/edit.xhtml">
             <ui:define name="label">Site</ui:define>
                <h:inputText id="site" size="75" required="false" />
                <rich:suggestionbox for="site" suggestionAction="#{siteUtil.searchSites}" var="_site" minChars="2" id="suggestion" width="500">
                   <h:column>
                   <h:outputText value="#{_site.name} - #{_site.alias}" />                                                                      
                </h:column>
                 <a:support ajaxSingle="true" event="onselect">
                    <f:setPropertyActionListener value="#{_site}" target="#{telephoneNumber.site}" />                              
                   </a:support>
                </rich:suggestionbox> 
          </s:decorate>       
          



          Not sure if it's right, but it seems to work.