【问题标题】:Disable an outputlink coming from database based on condition根据条件禁用来自数据库的输出链接
【发布时间】:2015-04-07 11:27:08
【问题描述】:

我正在开发一个应用程序,我遇到的情况是我从数据库中获取一些链接,基于这些链接进行更多的检索。如果基于此输出链接检索到空行,我想禁用输出链接。

我正在使用布尔结果处理 preRequisiteNull 并在 primefaces 中呈现输出链接,但如果只有一行具有真实值,它就会消失。

我的代码:

for(LabOrdersDTO laborderDto:labOrdersDTOListDataModel.getWrappedData())
{
    System.out.println("Speciman Name"+laborderDto.getTest());

    System.out.println(laborderDto.getLabNo());

    for(LabOrdersDTO laborderDto2:labTestPreReqList.getWrappedData())
    {
        System.out.println("Lab test"+laborderDto2.getTest());
        if(laborderDto2.getTestPreReq()!=null){

            preRequisiteNull = false;
        }else{
            preRequisiteNull = true;
        }
    }
}

【问题讨论】:

  • 不清楚问题是什么或您在问什么。

标签: jsf primefaces


【解决方案1】:

如果我对你的理解正确,那么你的错误就在你的 for 循环中。

如果一个链接=空,你想禁用链接吗?对吧?

如果是,那么如果一个链接为空,则必须中断循环,否则下一个 notNull 链接将覆盖该值。

替换这个

for(LabOrdersDTO laborderDto:labOrdersDTOListDataModel.getWrappedData())
{

    for(LabOrdersDTO laborderDto2:labTestPreReqList.getWrappedData())
    {
       if(laborderDto2.getTestPreReq()!=null){

            preRequisiteNull = false;
        }else{
            preRequisiteNull = true;
        }
    }
}

宽度:

for(LabOrdersDTO laborderDto:labOrdersDTOListDataModel.getWrappedData())
    {

        for(LabOrdersDTO laborderDto2:labTestPreReqList.getWrappedData())
        {
            if(laborderDto2.getTestPreReq()==null){        
                preRequisiteNull = true;
                // update the link state or no idea how you manage it to disable the link
                break;
            }
        }
    }

但是我看不到您如何将链接状态设置为禁用。如果一行是空的,我的建议会中断,但您必须更新该链接的状态!

【讨论】:

    猜你喜欢
    • 2019-01-13
    • 2020-05-05
    • 2020-11-01
    • 2018-05-11
    • 2018-02-24
    • 1970-01-01
    • 2014-12-17
    • 2016-12-30
    • 1970-01-01
    相关资源
    最近更新 更多