Pergunta

I'm using primefaces 5.0 and I have this situation:

<composite:implementation>

<p:dialog id="confirmDialog#{cc.attrs.someParam}"
    rendered="#{cc.attrs.nextState.warnRequired}" severity="alert" resizable="false" modal="#{cc.attrs.modal}"
    widgetVar="confirmation#{cc.attrs.someParam}">

    <p:commandButton value="#{msg[cc.attrs.nextState.buttonKey]}" icon="#{nextStatus.icon}"
        action="#{someActionCalled}"
        update="#{cc.attrs.update}" process="#{cc.attrs.process}"
        oncomplete="if (!args.validationFailed) { PF('confirmation#{cc.attrs.someParam}').hide(); }">
    </p:commandButton>

    
    <p:commandButton id="decline" value="#{msg['action.cancel']}" icon="ui-icon ui-icon-cancel"
        onclick="PF('confirmation#{cc.attrs.someParam}').hide()"  />

</p:dialog>


</composite:implementation>

When i click "decline" / cancel button, confirmDialog is closed / hides. Thats ok. Obviusly confirmation#{cc.attrs.someParam} can find widgetVar and closes this dialog.
But when i click first button to confirm and take some action in back bean i get :

Widget for var 'confirmationSomeParam' not available!
primef...mefaces (line 1)
detailed error: TypeError: PF(...) is null

{cc.attrs.someParam}

is passed into component. Its evaluated clean and values are there ( obviusly because second button can close dialog.
So its very strange that first button cant find this dialog widgetVar and second one can ?

Foi útil?

Solução

So i had time again to check this critical part of my application and im posting here so someone in future maybe will find this usefull :)

I have added p:remoteCommand under both buttons in code:

<p:remoteCommand name="somethingToDo" update="#{cc.attrs.update}" />

and in first button i have removed update param.

Why ? Because as error says, it could not find some dialogId ( in this example 'confirmation332m' ) and because of that update param, which was updating whole form, dialog was removed / updated.

So i moved update param from button to remote command and in onComplete i just call somethingToDo(); after all validation is checked.

Maybe its not best solution but for now it works ;)

PF forum link ( for future problems ): http://forum.primefaces.org/viewtopic.php?f=3&t=37851

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top