You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by vlad10 <iv...@yahoo.com> on 2007/06/29 00:32:33 UTC
Tomahawk: dataTable with detailToggle problem
I'm trying to use 'lazy' model initialization (with hibernate on the back)
for the t:dataTable with detailToggle, so that when I click 'Show Orders',
the actionListener would call methot which retrieves all necessary records
(I'm following the example on http://www.irian.at/myfaces/home.jsf):
<t:dataTable value="#{customers.list}"
id="data"
var="customer"
varDetailToggler="detailToggler"
preserveDataModel="true"
styleClass="customers"
headerClass="customersHeader" columnClasses="custid,name">
.....columns here and in one column this:
<h:commandLink rendered="#{!detailToggler.currentDetailExpanded}"
actionListener="#{customers.showOrders}"
action="#{detailToggler.toggleDetail}">
<h:outputText value="Show Orders" />
</h:commandLink>
... then a similar link with "Hide Orders"
... then <f:facet name="detailStamp"> with inner dataTable for details
customers Bean:
public void showOrders(ActionEvent e) {
UIComponent c = e.getComponent();
log.debug("showOrders : " + c.getId());
Customer row = list.get(getIndex(c));
if (row.getCustomerOrder() == null)
getOrders(row);
}
It seems that the custom tag requires detailes being initialized right away.
I see hibernate error in stack trace saying that it's trying to initialize
orders, when the session is already closed.
1. Am I missing some attribute that may be specified to help the matter????
2. In my commandLink I've added actionListener when action was already
specified, is it a valid technique??? All I need - call my bean to populate
model with required details some time early in the lifecycle prior to
executing "detailToggler.toggleDetail". Well, w/o resolving the first issue
I can't start playing with the second.
thanks
vlad
--
View this message in context: http://www.nabble.com/Tomahawk%3A-dataTable-with-detailToggle-problem-tf3997193.html#a11352179
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: Tomahawk: dataTable with detailToggle problem
Posted by Vladimir Isakovich <iv...@gmail.com>.
I just slept over this problem, and this is what I've done to resolve it:
I initiated collections of orders in all customers with empty collections:
list = (List<Customer>)super.getList("from
xyz.persist.domain.Customer");
for(int i=0; i< list.size(); i++) //initialize collections
list.get(i).setCustomerOrder(new HashSet());
This way the custom tag is happy since the Set of orders is not null
anymore.
Also my second problem (well - just anticipated problem) was not a problem
at all. My actionListener executed the bean method prior to
detailToggler.toggleDetail.
I'm still trying to understand what is the difference when attaching
actionListener as an attribute vs f:actionListener, and also how many
actionListeners I may attach to one component, and in what order they will
get executed. I'll experiment with those listeners.
On 6/28/07, vlad10 <iv...@yahoo.com> wrote:
>
>
> I'm trying to use 'lazy' model initialization (with hibernate on the back)
> for the t:dataTable with detailToggle, so that when I click 'Show Orders',
> the actionListener would call methot which retrieves all necessary records
> (I'm following the example on http://www.irian.at/myfaces/home.jsf):
>
> <t:dataTable value="#{customers.list}"
> id="data"
> var="customer"
> varDetailToggler="detailToggler"
> preserveDataModel="true"
> styleClass="customers"
> headerClass="customersHeader" columnClasses="custid,name">
> .....columns here and in one column this:
> <h:commandLink rendered="#{!detailToggler.currentDetailExpanded}"
> actionListener="#{customers.showOrders}"
> action="#{detailToggler.toggleDetail}">
> <h:outputText value="Show Orders" />
> </h:commandLink>
> ... then a similar link with "Hide Orders"
> ... then <f:facet name="detailStamp"> with inner dataTable for details
>
> customers Bean:
> public void showOrders(ActionEvent e) {
> UIComponent c = e.getComponent();
> log.debug("showOrders : " + c.getId());
> Customer row = list.get(getIndex(c));
> if (row.getCustomerOrder() == null)
> getOrders(row);
> }
>
> It seems that the custom tag requires detailes being initialized right
> away.
> I see hibernate error in stack trace saying that it's trying to initialize
> orders, when the session is already closed.
>
> 1. Am I missing some attribute that may be specified to help the
> matter????
>
> 2. In my commandLink I've added actionListener when action was already
> specified, is it a valid technique??? All I need - call my bean to
> populate
> model with required details some time early in the lifecycle prior to
> executing "detailToggler.toggleDetail". Well, w/o resolving the first
> issue
> I can't start playing with the second.
>
> thanks
> vlad
>
> --
> View this message in context:
> http://www.nabble.com/Tomahawk%3A-dataTable-with-detailToggle-problem-tf3997193.html#a11352179
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>