http://ofbiz.116.s1.nabble.com/jira-Created-OFBIZ-322-Form-widget-header-link-for-sorting-doesn-t-render-if-fields-have-use-whens-tp172593p172604.html
> Form widget header link (for sorting) doesn't render if fields have use-whens
> -----------------------------------------------------------------------------
>
> Key: OFBIZ-322
> URL:
http://issues.apache.org/jira/browse/OFBIZ-322> Project: OFBiz (The Open for Business Project)
> Issue Type: Bug
> Components: framework
> Affects Versions: SVN trunk
> Reporter: Jacques Le Roux
> Assigned To: Jacques Le Roux
> Priority: Minor
> Fix For: SVN trunk
>
>
> From Leon Torres in
http://jira.undersunconsulting.com/browse/OFBIZ-830> Ok this is a tricky bug to describe, so I'll do this by example. Suppose you have a form "ListParties" that you re-use all over and it needs two behaviors for the "partyId" field:
> 1. Normal behavior: Show the partyId as a hyperlink to the viewParty page.
> 2. LookupParty behavior: In a LookupParty popup that uses ListParties, have the partyId hyperlink do a javascript:set_value(partyId) instead.
> This is a common scenario, where one has to re-use a field for different purposes. The form widget supports this with the use-when attribute. One way to set it up is to use the same field name="" and give them both use-whens as follows,
> <field name="partyId" header-link="sortLink" use-when="isLookup==false">
> <hyperlink description="${partyId}" target="viewPartyLink?partyId=${partyId}"/>
> </field>
> <field name="partyId" use-when="isLookup==true">
> <hyperlink also-hidden="false" target-type="plain" description="${partyId}"
> target="javascript:set_value('${partyId}')"/>
> </field>
> So in a lookup form, only the second one will be used.
> The bug is that the header-link="sortLink" will not work. The sort link is not rendered in the header, preventing the user from sorting by partyId.
> However, if you swap the order of the field elements such that the header-link one is second, it will work.
> I traced this bug to ModelForm.java renderHeaderRow() where it decides how to render the header-link. The current code marked "Modification Nicolas" is not doing the right thing. It should be evaluating the use-when and comparing it to any other one before deciding to continue.
> For now the workaround is to make sure the header-link element comes after the other one.