I have a dialogue with a commandButton, and this is what I'm trying to do:

  1. Do some Java work
  2. Update a Primefaces tab
  3. Make my dialogue box disappear
  4. Go to that certain tab.

This is the code I'm using:

                <p:commandButton value="Submit"
                action="<some java work>"
                oncomplete="dialogue.hide(); sideTabs.select(1)"
                update="<update side tab">
            </p:commandButton>

The problem is, this only works once between refreshes. What I mean is, I click the button, and everything works fine-the tab changes to the requested tab, the tab is updated, and the dialogue disappears. But when I click the button again, the requested tab is indeed selected, but isn't properly refreshed until I hit f5. Once I do that, I can click the dialogue button again and the tab will properly refresh again, but once again, only once - until I hit f5 again. So, something like this:

  1. Click the button -> see 1 item in the tab
  2. Click the button again -> still see only 1 item in the tab
  3. Hit f5 -> see 2 items in the tab
  4. Click the button -> see 3 items in the tab
  5. Click the button again -> still see 3 items in the tab
  6. Hit f5 -> see 4 items in the tab etc...

Does anyone have an idea why this is happening? Do I need to add some page refresh mechanism to my commandButton? If so, how is this done? Thanks!!!

有帮助吗?

解决方案

I've tried to replicate the problem with no success.

Here is a the attribute from my ViewScoped bean:

private String str1 = "a";

private String str2 = "b";

private String update = ":f:t";

private Integer index = 0;

And here is the view:

<h:form id="f">
    <p:tabView id="t" widgetVar="tVar" activeIndex="#{viewMBean.index}" >
        <p:tab id="a" title="A" >
            #{viewMBean.str1}
        </p:tab>
        <p:tab id="b" title="B">
            #{viewMBean.str2}
        </p:tab>
    </p:tabView>
</h:form>

<p:dialog id="d" widgetVar="dVar">
    <h:form>
        <p:inputText value="#{viewMBean.str1}" />
        <br />
        <p:inputText value="#{viewMBean.str2}" />
        <br />
        <p:inputText value="#{viewMBean.update}" />
        <br />
        <p:inputText value="#{viewMBean.index}" />
        <br />
        <p:commandButton value="Submit" update="#{viewMBean.update}" oncomplete="dVar.hide();" />
    </h:form>
</p:dialog>

I believe the problem is somewhere else in your code.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top