2012-04-15 164 views
0

我想用primefaces打印机打印一个div(带有myfaces 2.0的primefaces 3.2)。Primefaces打印机打印div

我的脸代码如下:

  <div id="page"> 
       <!-- SIDEBAR --> 
       <div id="sidebar" 
        class="ui-widget-content ui-corner-all ui-helper-clearfix ui-shadow sidebar"> 
        <ui:insert name="sidebar"></ui:insert> 
        <p:commandButton value="Print" type="button"> 
         <p:printer target="content" /> 
        </p:commandButton> 
       </div> 

       <!-- CONTENT --> 
       <div id="content"> 
         <ui:insert name="content">...</ui:insert> 
       </div> 
       <div style="clear: both;">&nbsp;</div> 
      </div> 

但我得到一个FacesException:

javax.faces.FacesException: Cannot find component content in view. 

这可能与primefaces打印机或有另一种方式来做到这一点。

此致Veote

回答

1

p:printer期望组件的ID,但ui:insert定义了要由所述客户端被插入一个逻辑部分。你可以尝试打印你想打印的内容,如下所示:

<p:outputPanel id="content"> 
    <ui:insert name="content" /> 
</p:outputPanel> 
+0

好的这个作品,谢谢。但我不能打印图表:/你知道如何使用primefaces打印机打印primefaces图表吗? – veote 2012-04-17 06:39:14

+0

不确定你的意思是“图表”,但我建议你在新问题中提出这个问题,并发布你想要打印的“图表”的代码。 – jFrenetic 2012-04-17 15:49:52