Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bean call on ajax event with facelet ui:include + ui:param seems not to work ? #541

Open
Kristover opened this issue Nov 3, 2016 · 6 comments

Comments

@Kristover
Copy link

Kristover commented Nov 3, 2016

Hi,

With a simple facelet inclusion :

<ui:include src="/WEB-INF/xhtml/panels/editUserRegistrationPanel.xhtml">
        <ui:param name="beanCtrl" value="#{profilCtrl}" />
</ui:include>

The ajax bean call 'onchange' works perfectly when using directly the bean name ('profilCtrl') :

<b:inputText value="#{beanUser.prenom}" 
	        		     onchange="ajax:profilCtrl.valueChanged()"
	        		     update="@(.btn) @next"
	        		     ajax="true" />

But if we use instead the include param 'beanCtrl' in the ajax call :

<b:inputText value="#{beanUser.prenom}" 
	        		     onchange="ajax:beanCtrl.valueChanged()"
	        		     update="@(.btn) @next"
	        		     ajax="true" />

(Note of course that value="#{beanUser.prenom}" is done correctly)

the call is not triggered and the following message appears in logs :
Please check your EL expression - intermediate term beanCtrl is null

Any idea ?
Many thanks in advance

(CDI context ; Wildfly 9.0.2 imports for bean are :
@javax.inject.Named(value="profilCtrl")
@javax.faces.view.ViewScoped (not javax.faces.bean.ViewScoped which doesn't work in CDI context)

@Kristover Kristover changed the title ajax bean call with facelet ui:include + ui:param = KO bean call on ajax event with facelet ui:include + ui:param seems not to work ? Nov 5, 2016
@Kristover
Copy link
Author

Hi,

i answer to my own question :
It seems that i encounter a problem between taghandlers / UI Components incompatibility.

  • My ui:include which is a taghandler is executed during view build time.
  • On the other hand, the ajax event part is built during view render time i think, and then executed after on the client side without accessibility to a managed bean.

ui:include could help in code mutualization, but it implies less flexibility when we encounter such problems... (i.e. also dynamic tabs with ui:include)

@Kristover
Copy link
Author

Kristover commented Nov 15, 2016

Hi again,

Have you any solution to the problem ? i'm really embarrassed with this problem which prevent me to push the final release in prod.

i give some code to tests :

test.xhtml :

<h:body>
    <b:container fluid="true">
      <h:form>
               <b:row>
                <b:column>
                    <ui:include src="test_include.xhtml">
                        <ui:param name="beanCtrl" value="#{test}" />
                    </ui:include>
                    <b:commandButton disabled="#{test.disabled}" value="OK"></b:commandButton>
                </b:column>
            </b:row>
        </h:form>
        </b:container>
   </h:body>

test_include.xhtml :

<ui:composition ...><b:inputText value="#{beanCtrl.value}" onchange="ajax:beanCtrl.onChange()" update="@(.btn)"></b:inputText></ui:composition>

TestAction.java :

import java.io.Serializable; 
import javax.faces.view.ViewScoped;
import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Named("test")
@ViewScoped
public class TestAction implements Serializable {

    private String value = "Default";

    private static final long serialVersionUID = 745232242454805589L;

    final static Logger logger = LoggerFactory.getLogger(TestAction.class);

    boolean b = true;

    public TestAction() {
        super();
    }

    public void onChange(){
        logger.debug("##### > OK");
        b = false;
    }

    public boolean isDisabled(){
        return b;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    } 

}```

Many thanks in advance for any answer

Regards

@stephanrauh
Copy link
Collaborator

Oh, sorry, I've read your question, but I didn't find some spare time to answer it yet. I guess it's my job to fix your bug. I'm afraid it's going to be a difficult one. If I'm lucky, I'm just using the wrong "EL context", and it's just a matter of choosing the correct one. But that's something I'm not familiar with, so I'll probably need some time to investigate the issue.

BTW, there's no need to be embarrassed: obviously, you've found a profound error in BootsFaces.

You don't happen to have a workaround so you can push your application into production?

@stephanrauh
Copy link
Collaborator

I'd also like to express my gratitude for providing a reproducer. That helps us a lot!

Merci et a tout a l'heur
Stephan

@Kristover
Copy link
Author

You don't happen to have a workaround so you can push your application into production?

No worry,
it's only the website of a boardgame association.
So members will wait until i stabilized all the stuff :-)

Christophe

@TheCoder4eu TheCoder4eu modified the milestones: v1.1.0, v1.0.1 Dec 9, 2016
@TheCoder4eu TheCoder4eu modified the milestones: v1.5.0, v1.1.0 Apr 15, 2017
@TheCoder4eu TheCoder4eu removed this from TO DO in BootsFaces v1.1.0 Apr 17, 2017
@stephanrauh stephanrauh removed their assignment Sep 24, 2017
@stephanrauh
Copy link
Collaborator

Confirmed the issue and added a test case to the showcase (/BootsFacesWeb/issues/issue541.jsf)

stephanrauh added a commit to TheCoder4eu/BootsFacesWeb that referenced this issue Aug 4, 2019
@TheCoder4eu TheCoder4eu modified the milestones: v1.5.0, v1.6.0 Aug 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants