0

maybe I am missing something very basic.

I have a p:autocomplete with an p:ajax event="itemSelect" child and forceSelection="true" attribute. When the user selects a value from the list I can update parts of the page from the itemSelect event. That works all fine. Now, I want also an page update when the user types something in the field. I would like to handle this as an unselect. Unfortunatedly I see no way to update when the complete-method is called. Even stuff like

final RequestContext requestContext = RequestContext.getCurrentInstance();
requestContext.update("content_form:table");

in the complete-method does not help.

Any ideas? I hope I expressed myself in a comprehensive way.

axel
  • 13
  • 5

1 Answers1

0

You can use one of the key Events like onkeyup, onkeydown etc

        <h:panelGrid id="components2update">
            <ui:param name="teststuff" value="#{areasBean.someValueThatgotUpdated}" />
            <p:outputLabel value="#{teststuff}" />
        </h:panelGrid>

        <p:autoComplete id="acSimple" value="#{someBean.someValue}"
            completeMethod="#{someBean.autoCompMethod}"
            .... >
            <p:ajax event="keyup" oncomplete="alert('ddd')"
                update=":#{p:component('components2update')}" />

        </p:autoComplete>
yannicuLar
  • 3,083
  • 3
  • 32
  • 50
  • This does not work if you want to update something depending on the results of `autoCompMethod`. The `keyUp` event is being triggered before `autoCompMethod` is even called. – Monkey Supersonic Nov 29 '18 at 12:02
  • @MonkeySupersonic, sounds like you want to conditionally update your components, so you better handle that logic on a backing bean, and have it calling the update, https://stackoverflow.com/questions/11365094/can-i-update-a-jsf-component-from-a-jsf-backing-bean-method?rq=1 – yannicuLar Nov 29 '18 at 12:16