-
1. Re: multiple calls to same method from <s:div rendered...>
asookazian Sep 25, 2007 5:16 PM (in response to asookazian)in SFSB:
public boolean getSeedSelection() { log.info("in seedSelection()"); populate(); return true; }
private void populate() { log.info("in populate()"); try { con = DriverManager.getConnection(AdminConstants.URL, AdminConstants.USERNAME, AdminConstants.PASSWORD); cstmt = con.prepareCall("{call usp_u_adm_select_Role}"); rs = cstmt.executeQuery(); choices = new ArrayList<SelectItem>(); while(rs.next()) { choices.add(new SelectItem(rs.getString("ApplicationRoleID"), rs.getString("Name"))); String name = rs.getString("Name"); log.info("populate(): name = " + name); String applicationRoleID = rs.getString("ApplicationRoleID"); log.info("populate(): applicationRoleID = " + applicationRoleID); } alreadyPopulated = "a value indicating we are populated"; } catch(Exception e) { e.printStackTrace(); } finally { this.cleanUp(); } //return allRolesHashMap; }
-
2. Re: multiple calls to same method from <s:div rendered...>
asookazian Sep 25, 2007 5:34 PM (in response to asookazian)only calls it once if getSeedSelection() returns false.
we're going to check for null on instance variables that are loaded (choices) to avoid DB round trips -
3. Re: multiple calls to same method from <s:div rendered...>
fhh Sep 25, 2007 6:31 PM (in response to asookazian)Why don't you use:
a.) Datasources. Opening connections is an expensive operation.
b.) Use a SELECT statement instead of a call to a stored procedure if you want to retrieve data.
c.) @Factory for choices?
d.) Use entities and <s:selectitems> to create select items.
e.) Use Hibernate caching to avoid db roundtrips.
f.) Use Seam's query object to retrieve a filtered list of entities.
No offense, but if your requirements are totally different from the "Seam way of doing things" (TM) you will propably be better off without it.
Regards
Felix -
4. Re: multiple calls to same method from <s:div rendered...>
amitev Sep 25, 2007 6:34 PM (in response to asookazian)And never in the jsf spec is told that your getter will be invoked only once per request
-
5. Re: multiple calls to same method from <s:div rendered...>
asookazian Sep 25, 2007 6:35 PM (in response to asookazian)thx for the feedback.
we are creating a Java version of existing C#/ASP.NET use cases using Seam. we are going to use the existing sprocs first and then convert them to pseudo-code/logic and use JPA entity beans from there. -
6. Re: multiple calls to same method from <s:div rendered...>
asookazian Sep 25, 2007 6:46 PM (in response to asookazian)"amitev" wrote:
And never in the jsf spec is told that your getter will be invoked only once per request
why would they allow it to be called more than once? in case of network or db connectivity problems?
seems the user would just refresh their browser/screen... -
7. Re: multiple calls to same method from <s:div rendered...>
amitev Sep 25, 2007 7:02 PM (in response to asookazian)It's not very good practice to put expensive logic in the getter/setter method
-
8. Re: multiple calls to same method from <s:div rendered...>
saeediqbal1 Sep 25, 2007 8:33 PM (in response to asookazian)JSF backing bean methods/getters can be called unlimited times. there is no set limit. Ofcourse its not only one time because we have experienced 4-6 times ourselves. So live with it and maybe do what we did. put a condition statement to check if the property was already set. otherwise return whatever it had
-
9. Re: multiple calls to same method from <s:div rendered...>
pmuir Sep 26, 2007 7:32 AM (in response to asookazian)Use lazy initialization - @Factory does this for you.