Passing a Character (vs passing String) to backing bean method in EL

前端 未结 2 931
隐瞒了意图╮
隐瞒了意图╮ 2021-01-23 02:51

I would like to call a setter directly from a command button and pass a value. My problem is that the setter is expecting a Character and jsf if passing it back as a String. Is

2条回答
  •  死守一世寂寞
    2021-01-23 03:18

    I have tried to use simple quotes directly without using charAt(0) tips ...

    and this work correctly when parameter type is char or Character.

    Example passing a character:

    #{manageItemHandler.dataEntryOp.setBomComplete('Y')}
    

    Example passing a String literal and a character constant:

    
    

    The code of traceUpdate() java method is following:

    @ManagedBean(name = "vC")
    @ViewScoped
    public class ActionViewController
    extends AbstractViewController
        {
        public String traceUpdate(String s, Character c)
            {
            System.out.println("s:" + s + " " + c);
            return "";
            }
    

    OR

    @ManagedBean(name = "vC")
    @ViewScoped
    public class ActionViewController
    extends AbstractViewController
        {
        public String traceUpdate(String s, char c)
            {
            System.out.println("s:" + s + " " + c);
            return "";
            }
    

    where Character as been replace by char

    This example run on Glassfish 4.1 using Primefaces 6.2.4.

提交回复
热议问题