Use var in composition dataTable

UI Components for JSF
Post Reply
arco
Posts: 11
Joined: 25 Jul 2017, 09:19
Location: Netherlands

15 Jul 2018, 08:41

When creating a composite like below, setting the var property dynamically, how to use that property in the composition itself for instance in the rowStyleClass property.
When using #{component.var.status} the var gives me a string instead of the status attribute of the actual record in the dataTable.

Code: Select all

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:c="http://java.sun.com/jsp/jstl/core"
  xmlns:composite="http://java.sun.com/jsf/composite">
<head><title>dataTable</title></head><body>
<composite:interface>
  <composite:attribute name="var"/>
  <composite:attribute name="value"/>  
</composite:interface>
<composite:implementation>
    <p:dataTable id="table" value="#{cc.attrs.value}" rowStyleClass="#{component.var.status}">
    <c:set target="#{component}" property="var" value="#{cc.attrs.var}"/>
    <composite:insertChildren/>    
  </p:dataTable>
</composite:implementation>
</body></html>

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

16 Jul 2018, 11:15

I suggest to **not** use c:set in here, tried using cc.attrs.var directly? And does it work with a plain jsf h:dataTable?

arco
Posts: 11
Joined: 25 Jul 2017, 09:19
Location: Netherlands

16 Jul 2018, 17:14

Using #{cc.attrs.var} in the var property gives me the same result, it's treated as a string instead of the actual record and gives me the error that status isn't a property of String.
Btw in all examples I found on the net the var property is set with c:set because that seems to be the only way to get it working in a composition.
And it works, from the outside you can name the var whatever you want and refer to it to fill up your columns. The only question is how to refer to it inside the composition itself.

arco
Posts: 11
Joined: 25 Jul 2017, 09:19
Location: Netherlands

18 Jul 2018, 10:41

Nobody any idea how to solve this ?

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

18 Jul 2018, 13:51

Since it is unclear how you actually use it (http://stackoverflow.com/help/mcve) it is hard for me to try to investigate (I do not know everything, not by a long shot, so trying to replicate might help me in my investigation).

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 36 guests