rowSelect event in a composite component

UI Components for JSF
Post Reply
Guillaume
Posts: 13
Joined: 28 Jul 2011, 14:06

28 Jul 2011, 18:31

Hi,

I'm developping a composite component containing a p:inputText, a p:commandButton that displays a dialog. In this dialog there is a p:dataTable. When I select an item in this dataTable, the dialog closes and the text field is updated with the selected value.
My problem is how to set the parameter "update" of the ajax event of my dataTable.
Here is my code:

Code: Select all

<cc:interface>
	<cc:editableValueHolder name="value" required="true" />
	<cc:attribute name="popupRows" required="false" />
	<cc:attribute name="popupColumns" required="false" />
	<cc:attribute name="popupSelection" required="false" />	
</cc:interface>

<cc:implementation> 
	<h:inputText id="custom_input_text" value="#{cc.attrs.value}" />
		
	<p:commandButton styleClass="omg-taglist" onclick="#{cc.attrs.id}_dialog_widget.show();" value="Show"/>

	<p:dialog id="taglist_dialog" resizable="false" modal="true" widgetVar="#{cc.attrs.id}_dialog_widget" visible="false" draggable="false">
		<p:dataTable id="search_tagList_dialog_dataTable" var="item"
			value="#{cc.attrs.popupRows}"
			selection="#{cc.attrs.popupSelection}" 
			selectionMode="single">

			<p:ajax event="rowSelect" update="[b]custom_input_text[/b]" oncomplete="#{cc.attrs.id}_dialog_widget.close();"/>
			
			<p:columns value="#{cc.attrs.popupColumns}" var="column"
				columnIndexVar="colIndex">
				<f:facet name="header">  
					#{column.header}  
				</f:facet>
				#{item[column.property]}  
			</p:columns>

		</p:dataTable>
	</p:dialog>
</cc:implementation>
And:

Code: Select all

<h:form id="myform">
	<cc:TagList id="mycc" value="#{mybean.value}" popupRows="#{mybean.rows}" popupColumns="#{mybean.columns}" popupSelection="#{mybean.selection}" />
</h:form>
This code doesn't work. But if replace:

Code: Select all

<p:ajax event="rowSelect" update="[b]custom_input_text[/b]" />
By

Code: Select all

<p:ajax event="rowSelect" update="[b]myform:mycc:custom_input_text[/b]" />
It works, but it's a composite component so i cannot specify literally the id of the component to update...

I'm using PrimeFaces 3.0.M3-SNAPSHOT and jsf 2.1.2

Thanks for any help!
Tomcat 7.0.42
JSF 2.2.3
PF 4.0

ss4pagm
Posts: 6
Joined: 27 Jul 2011, 21:34

12 Mar 2012, 18:47

Hi.
Try passing the string :formId:ccId (where formId is the id you gave to the form containing the composite component, and ccId is the id you gave to the CC) as a parameter (defined as an attribute) to your composite component, and using it in the update.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 24 guests