【问题标题】:p:dialogue displayed only after 2 clicks on the p:commandButtonp:dialogue 仅在单击 p:commandButton 2 次后显示
【发布时间】:2017-05-21 18:10:30
【问题描述】:

我正在尝试删除p:dataTable 的一行。

  • 第一次点击删除按钮,对话框无法显示。
  • 第二次单击删除按钮,将显示对话框,因此操作成功完成。

Bean 是:

@Component()
@Scope("request")
public class ListTrainings 
{
	@Autowired
	public ListTrainings(@Qualifier("applicationManager") ApplicationManager appMgr)
	{
	   this.appMgr= appMgr;
	   lfs  =  new  ArrayList<Formation>();
	   tm  =  new TrainingModel();
	   formation = new  Formation();
	}
		
	@PostConstruct
	public void Initialize()
	{
	   System.out.println("Hello World");
	}

	public  void  selectedRow()
	{
	   status1 =  false;
	   status2 =  false;
	   tm  =  (TrainingModel)  listDatas.getRowData();
	   formation =  appMgr.listTrainingsByRef(tm.getId()).get(0);
	   vb.setFormation(formation);		
	   if(
                  (appMgr.listTrainersByRefTraining(formation.getFormationId()).size()  == 0)
                  &&
                  (formation.getSalleEspace() == null)
             )
	     { status1 =  true; }
	     else
	     { status2 =  true; }
	}
}

XHTML 上的按钮是:

<p:commandButton id="btn"
    		 value="3" 
    		 oncomplete="if(#{listTrainings.status1}) {PF('dlg1').show();}
    		             if(#{listTrainings.status2}) {PF('dlg3').show();}"
    		 update="aw">
       <f:ajax render="btn" execute="@all" listener="#{listTrainings.selectedRow}" />
</p:commandButton>

你能告诉我有什么问题吗?

【问题讨论】:

    标签: primefaces jsf-2.2


    【解决方案1】:
      <p:commandButton value="Basic" type="button" onclick="PF('dlg1').show();" />
    

    当按钮操作单击时,通过 p:dialog 使用小部件名称。onclick 方法的此按钮按小部件名称调用。添加对话框如下代码。

    <p:dialog header="Basic Dialog" widgetVar="dlg1" minHeight="40">
    <h:outputText value="Resistance to PrimeFaces is futile!" />
    

    【讨论】:

    • 你好@hsntpn,非常感谢您的回复,但我想在 onclick 上使用条件(如果 ... 如果 ..),就像我在问题中提到的那样。
    猜你喜欢
    • 1970-01-01
    • 2018-04-29
    • 2016-07-03
    • 2015-09-01
    • 2023-03-22
    • 2021-01-05
    • 2023-03-16
    • 2014-10-02
    • 1970-01-01
    相关资源
    最近更新 更多