You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Jan Bols <ja...@ivpv.ugent.be> on 2005/04/13 12:37:39 UTC

set properties of bean managed by dataTable tag

I have a jsf-page containing the following:
<f:view>
	<h:dataTable var="contact" value="#{allContacts.contactList}">	
	    <h:outputText value="#{contact.firstname}" />
	</h:dataTable>
</f:view>

The allContacts bean is a managed bean and is specified in the web.xml  
file:
<faces-config>
	<managed-bean>
		<managed-bean-name>allContacts</managed-bean-name>
		<managed-bean-class>MyContacts</managed-bean-class>
		<managed-bean-scope>session</managed-bean-scope>
	</managed-bean>
</faces-config>


The allContacts bean contains a list contactList containing contact-beans.  
The contact bean contains a property called myConnection that holds the  
connection to the database.

I want to set that connection property from within the jsf-page or the  
web.xml file but how do I do that? In jstl this can be done with <c:set>  
or in jsp with <jsp:setProperty> but how do I do this in jsf?

Thanks
Jan

Re: set properties of bean managed by dataTable tag

Posted by Jan Bols <ja...@ivpv.ugent.be>.
That's not what I meant. I want to set the database connection property of  
each Contact bean to a Connection object that is stored in sessionScope.  
The Contact beans are stored in an ArrayList called contactList of the  
allContacts bean. By using the <h:dataTable> I get a reference to each  
contact bean stored in the contactList of my managed bean allContacts. So  
I have a reference to each contact bean and now I want to set the database  
connection property of each contact bean to the Connection object stored  
in sessionScope.

First I though of specifying this in <faces-config> in the web.xml file  
but I can't because the number of Contact beans stored in the contactList  
of the allContacts managed bean aren't known in advance. This means I  
can't make each Contact bean of the contactList a managed bean.

Greetings
Jan

On Wed, 13 Apr 2005 07:56:52 -0500, Heath Borders  
<he...@gmail.com> wrote:

> You can set the property using an <h:inputText /> inside your datatable.  
> As
> your datatable interates over the rows in the contactList, you can edit  
> each
> contact bean independently.
>
>  On 4/13/05, Jan Bols <ja...@ivpv.ugent.be> wrote:
>>
>> I have a jsf-page containing the following:
>> <f:view>
>> <h:dataTable var="contact" value="#{allContacts.contactList}">
>> <h:outputText value="#{contact.firstname}" />
>> </h:dataTable>
>> </f:view>
>
> The allContacts bean is a managed bean and is specified in the web.xml
>> file:
>> <faces-config>
>> <managed-bean>
>> <managed-bean-name>allContacts</managed-bean-name>
>> <managed-bean-class>MyContacts</managed-bean-class>
>> <managed-bean-scope>session</managed-bean-scope>
>> </managed-bean>
>> </faces-config>
>>
>> The allContacts bean contains a list contactList containing  
>> contact-beans.
>> The contact bean contains a property called myConnection that holds the
>> connection to the database.
>>
>> I want to set that connection property from within the jsf-page or the
>> web.xml file but how do I do that? In jstl this can be done with <c:set>
>> or in jsp with <jsp:setProperty> but how do I do this in jsf?
>>
>> Thanks
>> Jan
>>

Re: set properties of bean managed by dataTable tag

Posted by Heath Borders <he...@gmail.com>.
You can set the property using an <h:inputText /> inside your datatable. As 
your datatable interates over the rows in the contactList, you can edit each 
contact bean independently.
 <f:view>
<h:dataTable var="contact" value="#{allContacts.contactList}">
 <h:column>
<h:outputText value="#{contact.firstname}" />
 </h:column>
 <h:column>
<h:inputText value="#{contact.myConnection}"/>
 </h:column>
</h:dataTable>
</f:view>
 Don't forget to define your datatable columns.

 On 4/13/05, Jan Bols <ja...@ivpv.ugent.be> wrote: 
> 
> I have a jsf-page containing the following:
> <f:view>
> <h:dataTable var="contact" value="#{allContacts.contactList}">
> <h:outputText value="#{contact.firstname}" />
> </h:dataTable>
> </f:view>

  
The allContacts bean is a managed bean and is specified in the web.xml
> file:
> <faces-config>
> <managed-bean>
> <managed-bean-name>allContacts</managed-bean-name>
> <managed-bean-class>MyContacts</managed-bean-class>
> <managed-bean-scope>session</managed-bean-scope>
> </managed-bean>
> </faces-config>
> 
> The allContacts bean contains a list contactList containing contact-beans.
> The contact bean contains a property called myConnection that holds the
> connection to the database.
> 
> I want to set that connection property from within the jsf-page or the
> web.xml file but how do I do that? In jstl this can be done with <c:set>
> or in jsp with <jsp:setProperty> but how do I do this in jsf?
> 
> Thanks
> Jan
> 



-- 
-Heath Borders-Wing
hborders@mail.win.org