ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbuch4 <hb...@straussauto.com>
Subject Re: don't call Managed Bean init method
Date Fri, 15 Aug 2008 16:53:53 GMT

Here is what I mean, for those who need an example:

My jsp iterates over the list returned by
ScheduleWeekBean.getScheduleWeeks() and prints out all week end dates:

<rich:panel styleClass="panel-main">
		<t:dataList value="#{scheduleWeekBean.scheduleweeks}" var="week"
			<rich:simpleTogglePanel styleClass="timecardbox" switchType="client"
				id="stp-30" opened="false">
				<f:facet name="header">
					<h:outputText value="#{week.weekenddate}">
						<f:convertNumber pattern="########" />

Then, in getScheduleWeekBean.getScheduleWeeks(), I retrieve the data from
the db:

public List getScheduleweeks() {
		try {
			scheduleweeks = new ArrayList(); 
			HashMap mymap = new HashMap(1);
	                mymap.put("homestore", "mystorename");
			List scheduleweekbeans = ScheduleControl.getScheduleWeek(mymap);
			Iterator it = scheduleweekbeans.iterator();
			while (it.hasNext()) {
				ScheduleWeekBean swb = (ScheduleWeekBean)it.next(); 
			System.out.println("done picking scheduleweek");	
		} catch (SQLException e) {
			// TODO Auto-generated catch block
		return scheduleweeks;

this seems simple, but it's different from what I'm used to doing, which is
DB retrieval in an init() method or a constructor, and then a very dumb
"get" method, such as:

public List getScheduleweeks() {
	return scheduleweeks;

I think the smart "get" method works better because JSF is component-based
and this way different bean methods can produce different structures of
beans as different "views" for the jsp pages, instead of requiring entirely
different beans for each view. 


Heather Buch (in a long conversation with herself)

hbuch4 wrote:
> Is there any way to prevent Ibatis from calling the init method of my
> ManagedBean, when it creates a new bean for a ResultMap?
> I only want to call the ManagedBean's init method when it is being
> instantiated through MyFaces, NOT through Ibatis. The only solution I
> thought of was, before the init method, to iterate through the stack trace
> and skip over if it finds: 
> at com.ibatis.common.beans.ClassInfo.instantiateClass
> but execute if:
> at org.apache.myfaces.shared_impl.util.ClassUtils.newInstance
> but this seems a little clunky.....
> any ideas?
> thanks, Heather Buch

View this message in context: http://www.nabble.com/don%27t-call-Managed-Bean-init-method-tp18989735p19002040.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.

View raw message