0

I have two managed beans NavigationState and ClientManagerboth are viewScope.

NavigationStatehas the getContentPage() method that is referenced on the viewAction:

<c:metadata>
    <c:viewAction action="#{navState.init('client', 'clientDetails')}"/>
</c:metadata>

ClientManagerhas the searchingClients method that is referenced on the bootsfaces inputText

 <b:inputText placeholder="nome" id="name"
                value="#{clientManager.clientOnSearch.firstName}"
                style="background: rgb(251, 251, 251) none repeat scroll 0% 0%;
                    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);">
            <c:ajax execute="name" event="keyup" 
            listener="#{clientManager.searchingClients()}" />       
            </b:inputText>

When I type a key on this input text field the only method called is the getContentPage() from the NavigationStateand not the searchingClients() from clientManager

Any idea why this is happening ?

Thank you

Bruno

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
b.lopes
  • 395
  • 1
  • 5
  • 15
  • getContentPage()? Your metadata section doesn't mention getContentPage(). Maybe a typo? – Stephan Rauh Apr 15 '16 at 22:42
  • I'm not an expert with these f:ajax facets - but shouldn't it be `listener="#{clientManager.searchingClients}` (without parentheses)? – Stephan Rauh Apr 15 '16 at 22:45
  • since bootsfaces key events attrs are not working fine I won't use this one. thanks – b.lopes Apr 17 '16 at 14:22
  • @b.lopes Did you check your question and the snippet code again, after Stephan's comment? It looks a bit odd, that you're referring to `navState.getContentPage()` , if the viewAction itself only uses `navState.init`. Is it a typo or intended? – Zhedar Apr 21 '16 at 22:44
  • Using different XML namespace prefixes than documented is genuinely confusing. The `c` prefix is documented for JSTL core tags, not JSF core tags. Try to not deviate from the standards. – BalusC Apr 22 '16 at 07:12

1 Answers1

0

Usage of viewAction

First things first, check if you really need to use a viewAction, you may as well just use a simple @PostConstruct in your backing bean instead. (See this answer if you want to learn more about the differences.)

At the moment it looks like the viewAction is fired on every GET requests. However I'm not familiar with viewActions internal, maybe your backing bean is request scoped and therefore gets initialized on every ajax request?

It may help, if you get rid of it. If you don't need viewParams, just use @PostConstruct instead.

Ajax with BootsFaces

How does your clientManager.searchingClients() method's signature look like?
If it looks like clientManager.searchingClients(AjaxBehaviorEvent e), using parantheses won't work, you must opt for clientManager.searchingClients then.

Otherwise I don't see any errors in your JSF markup, it's exactly as in the showcase's first example.

However, I never really used f:ajax (or c:ajax in your case). It's always a bit quirky. But you also don't have to: In case of PrimeFaces there's p:ajax and in case of BootsFaces we got our own recommended way of invoking ajax listeners.

So maybe you want to give this a try:

 <b:inputText placeholder="nome" id="name"
     value="#{clientManager.clientOnSearch.firstName}"
     style="background: rgb(251, 251, 251) none repeat scroll 0% 0%;
            box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);"
     onkeyup="ajax:clientManager.searchingClients()"/>

While trying the current 0.8.1 Showcase I found, that the InputText ajax example didn't quite work, so I will investigate, if this is caused by 0.8.1 or an old version of the showcase. It works in the Snapshot Showcase though.

Community
  • 1
  • 1
Zhedar
  • 3,290
  • 1
  • 19
  • 41