Technote

(FAQ)
How to use the <wcbase:useBean> tag with a custom non-key finder
How do you use the <wcbase:useBean> tag with a custom non-key finder?


Answer

By default, the JSTL <wcbase:useBean> tag activates the bean based on the primary key (that is, findByPrimaryKey). But if a new non-key finder (one that looks up the entity based on something other than the primary key) is created, update the EJB bean for the <wcbase:useBean> tag to be able to use that new finder.
As an example:

<wcbase:useBean id="orderBean" classname="com.ibm.commerce.order.beans.OrderDataBean" scope="page">
<c:set value="${orderId[0]}" target="${orderBean}" property="OrderId"/>
</wcbase:useBean>

will translate into a call of:

OrderDataBean.setOrderId (${orderId[0]} )
(ie. <BeanName>.set<Property> method)

You must modify the setter (setOrderId in this example) to use your custom (non-key) finder:

setOrderId()
{
//run custom non-key finder
findBySomeNonKey();
}

using a non-key finder does not necessarily return a distinct result, and thus the enumeration type should be used to handle the possibility that multiple beans are returned.
Cross Reference information
Segment Product Component Platform Version Edition
Commerce WebSphere Commerce Business Edition Development AIX, i5/OS, Linux, Solaris, Windows 5.6, 5.6.1, 5.6.1.1, 5.6.1.2, 5.6.1.3, 5.6.1.4
Commerce WebSphere Commerce - Express Development i5/OS, Linux, Windows 5.6, 5.6.1, 5.6.1.1, 5.6.1.2, 5.6.1.3, 5.6.1.4, 6.0, 6.0.0.1, 6.0.0.2, 6.0.0.3, 6.0.0.4
Commerce WebSphere Commerce Professional Edition Development AIX, i5/OS, Linux, Solaris, Windows 5.6, 5.6.1, 5.6.1.1, 5.6.1.2, 5.6.1.3, 6.0, 6.0.0.1, 6.0.0.2, 6.0.0.3, 6.0.0.4
Commerce WebSphere Commerce Developer Business Edition Development Windows 5.6, 5.6.1, 5.6.1.1, 5.6.1.2, 5.6.1.3, 5.6.1.4
Commerce WebSphere Commerce Developer Professional Edition Development Windows 5.6, 5.6.1, 5.6.1.1, 5.6.1.2, 5.6.1.3, 6.0, 6.0.0.1, 6.0.0.2, 6.0.0.3, 6.0.0.4
Commerce WebSphere Commerce Developer Express Development Windows 5.6, 5.6.1, 5.6.1.1, 5.6.1.2, 5.6.1.3, 5.6.1.4, 6.0, 6.0.0.1, 6.0.0.2, 6.0.0.3, 6.0.0.4
Commerce WebSphere Commerce Developer Enterprise Development Windows 6.0, 6.0.0.1, 6.0.0.2, 6.0.0.3, 6.0.0.4 All Editions
   

Document Information

Current web document: http://www.ibm.com/support/docview.wss?uid=swg21248067