1

When I click on search button, it will display search results based on conditions we entered or in total, so that time if search results are more than 100 it will display a warning message and will update search results based on conditions we entered.

MyForm.java

public String findList() {

    try {
        vwList = null;
        String ret = "self";
        rendered = false;

        long count = myEntryListService.findHistMasterCount(entryJyokenVO,formMode);

        System.out.println("count: " + count);
        if (count > CommonConst.MAX_ROW) {
            List msgList = new ArrayList();
            String params[] = new String[]{"WW000001", String.valueOf(CommonConst.MAX_ROW), String.valueOf(count)};
            msgList.add(params);
            ShowErrMsg.saveErr(msgList);
            System.out.println("warning message: " + FacesContext.getCurrentInstance().getMessages().next().getDetail()); // here getting warning message
    //      ret = "self"; //updated list is displaying but warning message not displaying
            ret = null; // warning message displaying but updated search results not displaying
        }

        vwList = myEntryListService.findHistMasterList(entryJyokenVO, formMode);
        rendered = true;
        System.out.println("vwList size: " + vwList.size());

        return ret;
    } catch (Exception e) {
        System.out.println("System error");

        return "error";
    }
}

agent.xhtml

<h:commandButton id="search" value="#{msgs['label.button.search']}" action="#{myForm.findList}" onclick="openLoadingWindow();"/>

faces-config.xml

<navigation-rule>   
    <from-view-id>/jsp/agency/agent.xhtml</from-view-id>
    <navigation-case>
        <from-outcome>self</from-outcome>
        <to-view-id>/jsp/agency/agent.xhtml</to-view-id>
        <redirect/>
    </navigation-case>
</navigation-rule>

Now the problem is,

  • If I am returning self and selected value from drop-down in screen, then updated search results are displaying corresponding to drop-down value, but warning message not displaying ...

  • If I am returning null and selected value from drop-down in screen, then warning message displaying but updated search results are not displaying corresponding to drop-down value (if I clicked search button 2 times after selecting value from dropdown then updated results list is displaying)...

User0123
  • 159
  • 2
  • 11

1 Answers1

2

You can try this. It may resolve your problem.

context.addMessage(clientId, facesMessage);    
context.getExternalContext().getFlash().setKeepMessages(true);

The original post I found here

Community
  • 1
  • 1
AppHouze
  • 206
  • 3
  • 10