2012-05-29 27 views
2

我在force.com apex模板的pageBlockSection内有一个表。这工作正常,直到我尝试使用其中一个单元格内的outputText标记。当我使用这个标签时,额外的单元格和行被添加到标记中。但是,如果我不将表嵌入pageBlockSection标记中,则不会添加这样的单元格。VisualForce中的嵌套表问题

我使用outputText不正确,还是有force.com上的错误?

这里是最小的标记,将重现此问题:

<apex:pageBlock title="My Page Block">  
    <apex:pageBlockSection title="My Section"> 
    <table> 
     <tr><th>1</th><th>2</th></tr> 
     <tr> 
     <td> 
      <apex:outputText value="{0}"> 
      <apex:param value="one" /> 
      </apex:outputText> 
     </td> 
     <td> 
      <apex:outputText value="{0}"> 
      <apex:param value="two" /> 
      </apex:outputText> 
     </td> 
     </tr> 
    </table> 
    </apex:pageBlockSection>  
</apex:pageBlock> 

这里是force.com渲染输出:

<table> 
    <tbody> 
    <tr><th>1</th><th>2</th></tr> 
    <tr> 
     <td></td> 
     <td colspan="2" class="dataCol first ">one</td> 
    </tr> 
    <tr> 
     <td colspan="2" class="dataCol "></td> 
     <td></td> 
     <td colspan="2" class="dataCol ">two</td> 
    </tr> 
    <tr> 
     <td colspan="2" class="dataCol last "></td> 
    </tr> 
    </tbody> 
</table> 

回答

4

无论它实际上是我不能说错误,但我相信这是由<apex:pageBlockSection>造成的,因为这些会自动将嵌套内容添加到表中,然后与您自己的表冲突。

我建议要么去除<apex:pageBlockSection>,并把你的表直接进入<apex:pageBlock>或删除自己的表和利用<apex:pageBlockSectionItem>元素来代替:

<apex:pageBlock title="My Page Block">  
    <apex:pageBlockSection title="My Section"> 
    <apex:pageBlockSectionItem > 
     1 
    </apex:pageBlockSectionItem> 
    <apex:pageBlockSectionItem > 
     2 
    </apex:pageBlockSectionItem> 
    <apex:pageBlockSectionItem > 
     <apex:outputText value="{0}"> 
     <apex:param value="one" /> 
     </apex:outputText> 
    </apex:pageBlockSectionItem> 
    <apex:pageBlockSectionItem > 
     <apex:outputText value="{0}"> 
     <apex:param value="two" /> 
     </apex:outputText> 
    </apex:pageBlockSectionItem> 
    </apex:pageBlockSection> 
</apex:pageBlock> 
1

我能够通过放置来解决这个问题一个outputPanel标签内的表。

<apex:pageBlockSection> 
    <apex:outputPanel> 
     <table> 
     </table> 
    </apex:outputPanel> 
</apex:pageBlockSection>