DynaForm and composite components

Community Driven Extensions Project
tdtappe
Posts: 29
Joined: 12 Sep 2011, 09:08

15 Aug 2012, 11:48

I just noticed some naming container problem with dynaForm and composite components.
Obviously a composite component's cc.clientId contains a "r...c...reg" (depending on the row and column number). But it cannot be referenced by this id. Nor can its children. If I just ignore this part of the id I can reference the component (or its children).
Can anybody confirm this? Is there anything I can do about it?
Using
Primefaces 6.2.14
Extensions 6.2.10
Mojarra 2.2.13
Wildfly 13.0.0.Final

User avatar
Oleg
Expert Member
Posts: 3803
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

15 Aug 2012, 12:54

Do you mean CC inside pe:dynaFormControl tag? But this is normal. Every component inside DynaForm gets prepended ID because DynaForm is a NamingContainer. If you place your CC inside p:dataTable e.g., you will get the same prepending. Prepended ID is generated by UIData at runtime. For DynaForm it looks like e.g. as "dynaForm:r1c2reg". Where "dynaForm" is the ID of the pe:dynaForm and "r1c2reg" says "the component is placed in the 1. row, 2. column in regular view area". Sure, you can reference your CC and any other component inside DynaForm by ID. DynaForm takes care about proper resolving. There is no difference in comparison to other UIData components as I said. You don't need to know about "r1c2reg"!

Show you code please if you have trouble.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

tdtappe
Posts: 29
Joined: 12 Sep 2011, 09:08

15 Aug 2012, 13:55

I am talking about a composite component used as a component for a dynaFormControl:

Code: Select all

<pe:dynaForm id="dynaForm" value="#{dynaFormHandler.model}">
	<pe:dynaFormControl type="consignor" for="consignor">
		<td:address id="consignor" value="#{dynaFormHandler.workingObject.consignor}" />
	</pe:dynaFormControl>
</pe:dynaForm>
If I display the cc.clientId inside td:address I get an id containing r1c1reg (or similar). Is this by design?
If so, how would I reference for example another component inside td:address? I was only successful with a fully qualified id.
But the only way I can think of to build a fully qualified id is to use cc.clientId. But it doesn't work because it contains r1c1reg or something. If I remove r1c1reg it works like a charm.
Using
Primefaces 6.2.14
Extensions 6.2.10
Mojarra 2.2.13
Wildfly 13.0.0.Final

User avatar
Oleg
Expert Member
Posts: 3803
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

15 Aug 2012, 14:06

If I display the cc.clientId inside td:address I get an id containing r1c1reg (or similar). Is this by design?
Sure. It is JSF. If you would place your <td:address .../> inside h:dataTable, p:dataTable, p:dataList, ... even inside h:form without prependId="false", you will get the same result! JSF standrad prepends in table e.g. something with tableId:j_idt19:j_idt20. What is the problem? You haven't still described your problem. Where do you need clientId?
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

tdtappe
Posts: 29
Joined: 12 Sep 2011, 09:08

15 Aug 2012, 14:35

As I said the problem is to reference another child component inside the composite.
Imagine the following:

Code: Select all

<composite:implementation>
	<p:autoComplete id="value" value="#{cc.attrs.value}" var="record" converter=...>
		<p:ajax event="itemSelect" update="#{cc.attrs.update} info" />
		<p:column>
			<h:outputText value="#{record.name}" />
		</p:column>
		...
	</p:autoComplete>
	<h:outputText id="info" value="#{cc.attr.value.info}" />
	...
This way it doesn't update "info" (component not found). If I use a fully qualified name (which doesn't seem to conatin r1c1reg) it works.
But how to get the fully qualified name/id of "info"? I can't prepend cc.clientId as it contains the r1c1reg stuff.

Maybe it's absoluetly not related to dynaForm. But so far I didn't have any problems prepending the clientId anywhere else in my app.
Using
Primefaces 6.2.14
Extensions 6.2.10
Mojarra 2.2.13
Wildfly 13.0.0.Final

User avatar
Oleg
Expert Member
Posts: 3803
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

15 Aug 2012, 15:03

This is really not related to DynaForm. Try this

Code: Select all

<p:ajax event="itemSelect" update="#{cc.attrs.update} @(##{cc.client}:info)" />
or any other jQuery selector or put the entire CC in a div http://www.ibm.com/developerworks/java/ ... .html#wrap I don't know.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

tdtappe
Posts: 29
Joined: 12 Sep 2011, 09:08

15 Aug 2012, 16:00

I tried a surrounding div without success. And using jQuery selector wasn't successful either. Though I am not sure I used it correctly.
Some variants let me run into javascript errors complaining about "mainForm" which is the first part of the fully qualified id.
And sometimes I don't get any errors but it just doesn't update the selected id.

BTW, I assume you wanted to write "cc.clientId" instead of "cc.client"!? And what about the double "#" at the beginning?

Anyway - thanks a lot so far. I hope I can solve this problem and use dynaForm - it's cool!!! :-)
Using
Primefaces 6.2.14
Extensions 6.2.10
Mojarra 2.2.13
Wildfly 13.0.0.Final

User avatar
Oleg
Expert Member
Posts: 3803
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

15 Aug 2012, 16:42

My idea was to use PFS (PrimeFaces Selectors) feature. That means @(#someClientId) in render / update attr. Simple look in Firebug and figure out the clientId. This code

Code: Select all

@(##{cc.clientId}:info)
should be resolved as

Code: Select all

@(#clientIdOfCompositeComponent:info)
This is clientId of info component. But look Firebug first.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

tdtappe
Posts: 29
Joined: 12 Sep 2011, 09:08

15 Aug 2012, 17:01

Ahh, I see.

I tried it and it seems to work for @(#mainForm) as I can see the partial.render parameter including a "mainForm" in the post.
But I run into a javascript error when I try to use a different id like @(#mainForm:whatever). Though I checked for this to be an existing id with Firebug.

Error: Syntax error, unrecognized expression: whatever

Maybe a problem of the preceding colon?
Using
Primefaces 6.2.14
Extensions 6.2.10
Mojarra 2.2.13
Wildfly 13.0.0.Final

tdtappe
Posts: 29
Joined: 12 Sep 2011, 09:08

15 Aug 2012, 17:22

I also tried to escape the colons with a backslash (and double backslash) - but without success.
Using
Primefaces 6.2.14
Extensions 6.2.10
Mojarra 2.2.13
Wildfly 13.0.0.Final

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 0 guests