Reputation: 111
I am trying to include one panelGrid to another like a:
<h:panelGrid id="A" border="1" columns="1" style="width: 100%; text-align:center; display: table">
<h:panelGrid id="B" border="1" columns="3">
<h:outputText value="Name : "></h:outputText>
<h:inputText></h:inputText>
<h:commandButton value="Add"></h:commandButton>
</h:panelGrid>
</h:panelGrid>
I have generated html like :
<table id="j_idt1:A" border="1" style="width: 100%; text-align:center; display: table">
<tbody>
<tr>
<td><table id="j_idt1:B" border="1">
<tbody>
<tr>
<td>Name : </td>
<td><input type="text" name="j_idt1:j_idt3" /></td>
<td><input type="submit" name="j_idt1:j_idt4" value="Add" /></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
...the thing is panelGrid "B" is always aligned to left despite the css text-align:center :P
That's what I have in eclipse web editor :
and that's what I have in firefox :
So my question is how to locate included panelGrid(s) with eclipse wtp css editor?
Thanks
Upvotes: 2
Views: 1988
Reputation: 152
I don't think you are going about centering a panelGrid the right way. This has been discussed in several other questions on this site. panelGrid renders to a , a block level element. text-lign: center
will just center the text in it. You should use margin: 0 auto
to adjust the margins.
Look at these answers to help:
How to align PanelGrid to center? JSF-Primefaces
Center a div in CSS - Bad questions, good answer
Edit: I made a quick project with your page and was able to center all 3 panelGrids:
The code for it is below, (I added 10px top margins instead of 0 to more easily tell the panels apart):
<h:panelGrid id="A" border="1" columns="1" style="margin: 10px auto; width: 100%; ">
<h:panelGrid id="B" border="1" columns="2" style="margin: 10px auto; width: 460px">
<h:panelGrid border="1" columns="1" style="margin: 10px auto;">
<h:inputText style="width: 310px; " ></h:inputText>
</h:panelGrid>
<h:commandButton value="Add"></h:commandButton>
</h:panelGrid>
</h:panelGrid>
Upvotes: 1