BootsFaces-OSP icon indicating copy to clipboard operation
BootsFaces-OSP copied to clipboard

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

Open Kristover opened this issue 8 years ago • 6 comments

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 avatar Nov 03 '16 13:11 Kristover

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 avatar Nov 07 '16 13:11 Kristover

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

Kristover avatar Nov 15 '16 15:11 Kristover

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 avatar Nov 15 '16 21:11 stephanrauh

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

stephanrauh avatar Nov 15 '16 21:11 stephanrauh

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

Kristover avatar Nov 16 '16 12:11 Kristover

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

stephanrauh avatar Aug 04 '19 14:08 stephanrauh

I'm afraid development of BootsFaces has slowed down considerably. We'll never manage to address this issue. Let's close it.

stephanrauh avatar Aug 12 '24 15:08 stephanrauh