You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Stefan Gesigora <SG...@Software-architekten.de> on 2005/10/24 16:53:07 UTC

bind HtmlPanelGrid dynamically in datatable

Hi folks!

 

Problem:

I wanna show a Link in a datatable if the user has a specific right and
if he hasn't I wanna show only text.

If I use the rendered tag the text wasn't shown if rendered = false.

So I tried to put an HtmlPanelGrid into my datatable with the attribute:
binding="#{row.testPanel}" (row is the var for the rows...).

 

But it didn't work. I got error messages like this:

"Error setting property 'testPanel' in bean of type null"....

 

What can I do except writing a custom component....???

 

regards,

Stefan


Re: bind HtmlPanelGrid dynamically in datatable

Posted by Bruno Aranda <br...@gmail.com>.
You have to use the rendered attribute, and put two components:

<h:column>
<h:commandLink ... rendered="#{row.itemIsClickable}">
..
</h:commandLink>
<h:outputText ... rendered ="#{!row.itemIsClickable}">
</h:column>

Another choice is to use the displayValueOnly attribute of the
extended commandLink component:

<t:commandLink ... displayValueOnly="#{!row.itemIsClickable}"/>

Hope that helps,

Bruno

2005/10/24, Stefan Gesigora <SG...@software-architekten.de>:
>
>
>
> Hi folks!
>
>
>
> Problem:
>
> I wanna show a Link in a datatable if the user has a specific right and if
> he hasn't I wanna show only text.
>
> If I use the rendered tag the text wasn't shown if rendered = false.
>
> So I tried to put an HtmlPanelGrid into my datatable with the attribute:
> binding="#{row.testPanel}" (row is the var for the rows…).
>
>
>
> But it didn't work. I got error messages like this:
>
> "Error setting property 'testPanel' in bean of type null"….
>
>
>
> What can I do except writing a custom component….???
>
>
>
> regards,
>
> Stefan

Re: bind HtmlPanelGrid dynamically in datatable

Posted by fabio fornelli <fa...@wavegroup.it>.
Stefan Gesigora wrote:

> Hi folks!
>
> Problem:
>
> I wanna show a Link in a datatable if the user has a specific right 
> and if he hasn’t I wanna show only text.
>
> If I use the rendered tag the text wasn’t shown if rendered = false.
>
Hi ya!
what about this? a command link is rendered only when the boolean 
variable sessionScope.ucs.secGroup is set to true otherwhise an output 
text is displayed.

<h:commandLink value="UNLOCK" action="#{odgPwdHandler.unlockUser}" 
rendered="#{ (sessionScope.ucs.secGroup) }"
<f:param name="uid" value="#{result.userId}"/>
</h:commandLink>


<h:outputText value="UNLOCK" rendered="#{(not sessionScope.ucs.secGroup) 
}"/>

BTW you can embed this in a Datatable

cheers
fabio


> So I tried to put an HtmlPanelGrid into my datatable with the 
> attribute: binding=”#{row.testPanel}” (row is the var for the rows…).
>
> But it didn’t work. I got error messages like this:
>
> “Error setting property 'testPanel' in bean of type null”….
>
> What can I do except writing a custom component….???
>
> regards,
>
> Stefan
>


Re: bind HtmlPanelGrid dynamically in datatable

Posted by Mike Kienenberger <mk...@gmail.com>.
You can't bind something dynamically, because there's only one
HtmlPanelGrid in your component tree.   It's just used multiple times
with different data sets to render output.

I perform similar operations like this:

<h:column>
    <h:panelGroup>
        <h:commandLink rendered="#{mycondition}" ... />
        <h:outputText rendered="#{not mycondition}" ... />
    </h:panelGroup>
</h:column>

For what it's worth, the error you get is because the binding takes
place while the component tree is being built, not while the rows are
being rendered.    So row will always be null at that time of
execution.

On 10/24/05, Stefan Gesigora <SG...@software-architekten.de> wrote:
>
>
>
> Hi folks!
>
>
>
> Problem:
>
> I wanna show a Link in a datatable if the user has a specific right and if
> he hasn't I wanna show only text.
>
> If I use the rendered tag the text wasn't shown if rendered = false.
>
> So I tried to put an HtmlPanelGrid into my datatable with the attribute:
> binding="#{row.testPanel}" (row is the var for the rows…).
>
>
>
> But it didn't work. I got error messages like this:
>
> "Error setting property 'testPanel' in bean of type null"….
>
>
>
> What can I do except writing a custom component….???
>
>
>
> regards,
>
> Stefan