Hiding a Table cell

Hi,

i have a table, with 3 cells in a row. based on a column data in the database... i want to hide or display columns (every column contains one image and an hyperlink).

can some one tell me how to hide or display a cell information

or

how to hide h:graphicImage and h:commandLink

Thanks in Advance

[341 byte] By [narayanasgsa] at [2007-11-27 4:51:30]
# 1
You can use the JSF 'rendered' attribute or the CSS display:none; or visibility:hidden; properties.
BalusCa at 2007-7-12 10:05:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

[nobr]Hi, Balu Thanks for reply...

but.....how to check with the database value...i am getting fom bean... is there any way to check condition in jsf?

this is my code....

<table>

<tr>

<td align="center">

<h:graphicImage value="/images/a.gif" styleClass="button" />

<br/><br/>

<h:commandLink id="appa" action="#{f.showb}" styleClass="button1" value="Continue"/>

</td>

<td>

<h:graphicImage value="/images/b.gif" styleClass="button" />

<br/> <br/>

<h:commandLink id="appb" action="#{f.showa}" styleClass="button1" value="Continue"/>

</td>

</tr>

</table>

Thanks in Advance.[/nobr]

narayanasgsa at 2007-7-12 10:05:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

The 'rendered' attribute accepts any EL expression with a boolean outcome.

Some basic examples:

<h:someComponent rendered="#{myBean.booleanValue}" />

<h:someComponent rendered="#{myBean.intValue > 10}" />

<h:someComponent rendered="#{myBean.objectValue == null}" />

<h:someComponent rendered="#{myBean.stringValue != 'someValue'}" />

<h:someComponent rendered="#{!empty myBean.collectionValue}" />

<h:someComponent rendered="#{!myBean.booleanValue && myBean.intValue != 0}" />

<h:someComponent rendered="#{myBean.stringValue == 'oneValue' || myBean.stringValue == 'anotherValue'}" />

I however recommend you to use a dynamically sizeable h:dataTable or a static h:panelGrid instead of a plain HTML table.

BalusCa at 2007-7-12 10:05:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
You could also try using JavaScript to change the CSS style of display. It is quite easier.. but rendered is quite fine also..
Arch_Bytesa at 2007-7-12 10:05:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Hi Balu,

Thanks for your reply, i could solve my problem. but when i am using panelGrid to display columns, if one column is hidden...then i am missing the table layout...

<h:panelGrid columns="2">

<h:graphicImage value="/images/a.gif" rendered="#{focal.emp_access.keepAdmin =='Y' }" />

<h:graphicImage value="/images/b.gif" rendered="#{focal.emp_access.optionsAdmin =='Y' }" />

<h:commandLink id="appkeep" action="#{focal.showkeep}" value="Continue" rendered="#{focal.emp_access.keepAdmin =='Y'}"/>

<h:commandLink id="appoptions" action="#{focal.showoptions}" value="Continue" rendered="#{focal.emp_access.optionsAdmin =='Y'}"/>

</h:panelGrid>

in the above code if the second image is hidden , then i am getting the link in the first row. is there any way to control this behavior... ?

narayanasgsa at 2007-7-12 10:05:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Nest it in a h:panelGroup, keeping the rendered attribute on the image.
BalusCa at 2007-7-12 10:05:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
Can you give me sample code...please.
narayanasgsa at 2007-7-12 10:05:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...