Page 1 of 1

BroadleafCurrency.java

Posted: Sun Feb 16, 2014 9:19 pm
by nanix84
BroadleafCurrency entity has adminprestation annotations so I added it in load_admin_menu.sql
My problem is the currency code cannot be seen when "add currency" button is clicked

though when I checked the AdminPresentation structure, it defined "prominent = true" im wondering why it didn't show up on the add currency UI

Code: Select all

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "BLC_CURRENCY")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = "blCMSElements")
@AdminPresentationClass(friendlyName = "BroadleafCurrencyImpl_baseCurrency")
public class BroadleafCurrencyImpl implements BroadleafCurrency {

    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "CURRENCY_CODE")
    @AdminPresentation(friendlyName = "BroadleafCurrencyImpl_Currency_Code", order = 1, group = "BroadleafCurrencyImpl_Details", prominent = true)
    protected String currencyCode;

    @Column(name = "FRIENDLY_NAME")
    @AdminPresentation(friendlyName = "BroadleafCurrencyImpl_Name", order = 2, group = "BroadleafCurrencyImpl_Details", prominent = true)
    protected String friendlyName;

    @Column(name = "DEFAULT_FLAG")
    @AdminPresentation(friendlyName = "BroadleafCurrencyImpl_Is_Default", group = "BroadleafCurrencyImpl_Details", excluded = true)
    protected Boolean defaultFlag = false;

    @Override
    public String getCurrencyCode() {
        return currencyCode;
    }

    @Override
    public void setCurrencyCode(String code) {
        this.currencyCode = code;
    }

    @Override
    public String getFriendlyName() {
        return friendlyName;
    }

    @Override
    public void setFriendlyName(String friendlyName) {
        this.friendlyName = friendlyName;
    }

    @Override
    public boolean getDefaultFlag() {
        if (defaultFlag == null) {
            return false;
        }
        return defaultFlag.booleanValue();
    }

    @Override
    public void setDefaultFlag(boolean defaultFlag) {
        this.defaultFlag = new Boolean(defaultFlag);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof BroadleafCurrency)) {
            return false;
        }

        BroadleafCurrencyImpl currency = (BroadleafCurrencyImpl) o;

        if (currencyCode != null ? !currencyCode.equals(currency.currencyCode) : currency.currencyCode != null) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        int result = currencyCode != null ? currencyCode.hashCode() : 0;
        return result;
    }
}

Re: BroadleafCurrency.java

Posted: Mon Feb 17, 2014 11:25 am
by phillipuniverse
Can you show a screenshot?

Re: BroadleafCurrency.java

Posted: Mon Feb 17, 2014 7:56 pm
by nanix84
It shows on the grid currently but its not showing on the "Add" currency UI. Does it have to do with "@Id" annotation? Will upload the screenies shortly...

Re: BroadleafCurrency.java

Posted: Mon Feb 17, 2014 9:07 pm
by nanix84
Here's the images
Image

Image

Re: BroadleafCurrency.java

Posted: Mon Feb 17, 2014 10:12 pm
by phillipuniverse
Ah ha, I understand. This definitely looks like a bug.

The reason that it's hidden is because the currency code is anotated with @Id. Primary keys are usually something that you do not want to enter on the add item screen since you want the database to decide what that primary key is. For instance, we use the SEQUENCE_GENERATOR table to figure out what the next primary key is for our entities.

String fields have to be handled differently. I've opened an issue at https://github.com/BroadleafCommerce/Br ... issues/723, let us know there if you have any further questions or want to continue the discussion.

Re: BroadleafCurrency.java

Posted: Mon Feb 17, 2014 11:54 pm
by nanix84
Thanks Phillip! I was right that it was a bug.
Is this going to get pushed on upcoming releases?

------- EDITED

nevermind I just restructured the BL currency and created my own.
Put a long ID field in it and its working fine

Thanks ;)

Re: BroadleafCurrency.java

Posted: Wed Feb 19, 2014 2:43 am
by nanix84
And also when used on the @AdminPresentationToOneLookup()
it displays no value selected even if I already selected a currency. again this might something to do with the Id issue

Re: BroadleafCurrency.java

Posted: Wed Feb 19, 2014 11:10 am
by phillipuniverse
If you're using it with @AdminPresentationToOneLookup, use the lookupDisplayProperty and set it to "currencyCode":

Code: Select all

@AdminPresentationToOneLookup(lookupDisplayProperty "currencyCode")