-
1. Re: How to convert an Integer into a ValueExpression
idyoshin Dec 25, 2009 4:18 AM (in response to daxxy)you're overcomplicating.
your method getOfficeIdByAssetTag() could be used as the ReadOnly value expression:
o.officeId = #{myManagedBean.officeIdByAssetTag}
Regards!
Ilya Dyoshin
-
2. Re: How to convert an Integer into a ValueExpression
daxxy Dec 25, 2009 1:19 PM (in response to daxxy)Your solution didn't exactly work, but pointed me in the right direction. It seems that the component referenced in the restriction needs to be populated before you set the expression. At least that's how it seems from my vantage point.
Here's what actually worked:
First inject the entity that contains the property you want to restrict one. In my case I want to restrict on officeId, so that was the Office entity:
@In(required=false) Office office;
Prior to getting the restrictions via getRestrictions, you need to set the attribute on the entity with the value you want to restrict on.
I did this in my override of getRestrictions, but I guess this can be done at any step prior to getRestrictions. In my case, I wanted officeId if hostname was so here is the code I used:
if (hostname!=null) { office.setOfficeId(getOfficeIdByHostname()); }
Then I set the restriction, but the restriction can really be set in the constructor. The important thing is that the restriction exist and that the attribute referenced in the restriction be set prior to getRestriction.
This worked like a charm.
TDR