Jsf 在p:schedule标题中添加命令按钮

Jsf 在p:schedule标题中添加命令按钮,jsf,primefaces,schedule,Jsf,Primefaces,Schedule,如何在p:schedule中添加“自定义”按钮?我试着借助p:dataTable组件中的标题方面来完成这项工作,但没有成功 很抱歉一开始不清楚,有人编辑了我的问题的标题,这可能也没什么帮助,下面是代码片段的更多细节 我想做一些类似的事情: <p:tab title="#{bean.name}" value="bean" > <f:facet name="title">

如何在
p:schedule
中添加“自定义”按钮?我试着借助
p:dataTable
组件中的标题方面来完成这项工作,但没有成功


很抱歉一开始不清楚,有人编辑了我的问题的标题,这可能也没什么帮助,下面是代码片段的更多细节

我想做一些类似的事情:

                    <p:tab title="#{bean.name}" value="bean" >
                        <f:facet name="title">
                            <h:outputText value="#{bean.name}"/>
                            <p:selectBooleanButton styleClass="...">
                                <p:ajax converter="... />
                            </p:selectBooleanButton>
                        </f:facet>
                    </p:tab>


客户端所有的html都可以通过javascript(jquery,如果您愿意)进行操作

因此,如果您像这样创建日程安排和按钮:

<h:panelGroup id="mySchedule">
    <p:schedule value="#{scheduleView.lazyEventModel}" leftHeaderTemplate="today" centerHeaderTemplate="prev, title, next" rightHeaderTemplate="month, agendaWeek"/>

    <h:outputText value="#{bean.name}" id="scheduleOutputText"/>
    <p:commandButton styleClass="..." id="scheduleCommandButton"/>

</h:panelGroup>
如果将此脚本放在panelGroup中,并在每次通常通过ajax更新计划时更新panelGroup,则应在更新中再次添加和移动按钮和文本

<h:panelGroup id="mySchedule">
    <p:schedule value="#{scheduleView.lazyEventModel}" leftHeaderTemplate="today" centerHeaderTemplate="prev, title, next" rightHeaderTemplate="month, agendaWeek"/>

    <h:outputText value="#{bean.name}" id="scheduleOutputText"/>
    <p:commandButton styleClass="..." id="scheduleCommandButton"/>

    $("#scheduleCommandButton").insertBefore(".fc-left");
    $("#scheduleOutputText").insertBefore("#scheduleCommandButton");

</h:panelGroup>

$(“#scheduleCommandButton”).insertBefore(“.fc左”);
$(“#scheduleOutputText”).insertBefore(“#scheduleCommandButton”);
您还可以将文本和按钮放入panelgroup中,并通过dom操作移动它。只需确保使用了正确的选择器(我没有在上面的选择器前面添加表单id)。您也可以使用类选择器而不是id。这取决于你


但一定要小心使用。正如@JasperDeVries在一篇评论中提到的那样,破坏东西很容易。请谨慎、谨慎地使用它,并将其作为最后的手段

任何代码示例都将受到高度赞赏,以便找出代码中的错误。要更改默认文本,请添加primefaces showcase中提供的脚本:您在标题中编写datatable,但在图片和标记中有一个时间表?你把两个问题混在一起。。请不要那样做。创建具有良好标题和标签的独立问题。请看,我已经完全更新了这个问题,如果您仍然不理解这个问题,请告诉我您为什么不使用CSS来定位按钮?这正是我想要的,但是无论我选择什么类(fc工具栏,fc右侧)它只是在“schedule”组件后显示按钮,然后我怀疑您的选择器错误,或者它依赖于浏览器。我在我的(本地)展示中尝试了这一点,效果很好。但是,如果脚本部分需要放在“”中,可能会尝试。发现了问题,因为我使用的是tabview,日程安排不是默认的选定选项卡文档。ready没有看到按钮,因为它在单击选项卡之前没有重新定义,现在我只需尝试在tabview更改(可能使用ajax)上运行此脚本,但是在操作DOM时要小心:你可以很容易地打碎东西。@Kukeltje如果stackoverflow允许的话,我会在10小时内奖励你奖金,谢谢你!
$("#scheduleCommandButton").insertBefore(".fc-left");
$("#scheduleOutputText").insertBefore("#scheduleCommandButton");
<h:panelGroup id="mySchedule">
    <p:schedule value="#{scheduleView.lazyEventModel}" leftHeaderTemplate="today" centerHeaderTemplate="prev, title, next" rightHeaderTemplate="month, agendaWeek"/>

    <h:outputText value="#{bean.name}" id="scheduleOutputText"/>
    <p:commandButton styleClass="..." id="scheduleCommandButton"/>

    $("#scheduleCommandButton").insertBefore(".fc-left");
    $("#scheduleOutputText").insertBefore("#scheduleCommandButton");

</h:panelGroup>