-1

Recently, in a EL expression (using #{}), I have tried to pass a String parameter delimited by double quotes as first parameter of a java method using following code

<p:panel style="border:none;#{vC.traceUpdate("p:panel")}">

but this line is refused because double quote are use to limit style attibute and to limit traceUpdate parameter.

I have found an easy solution that consist to use simple quote instead of double quote to limit style attribute as show in following code

<p:panel style='border:none;#{vC.traceUpdate("p:panel")}'>

But what do happening if first method's parameter type is String and next parameter's type is char as show in following code ?

<p:panel style='border:none;#{vC.traceUpdate("p:panel",'X')}'>

In this extreme situation, it is not more possible to exchange quote and double quote.

I have tried followed code, but this is refused (highlight in red on Intellij-Idea) and crashes application !

<p:panel style="border:none;#{vC.traceUpdate(\"p:panel\",'X')}">

How can I solve this problem ?

This question is not a duplicate because my question explicitely explain that problem is linked to double quotes ... and my question is how to pass a String AND a Char to a java method in EL expression

schlebe
  • 3,387
  • 5
  • 37
  • 50

1 Answers1

0

I'm thinking that the best answer found is to use '<string>'.charAt(0) as proposed by BalusC in [Passing a Character (vs passing String) to backing bean method in EL

<p:panel style="border:none;#{vC.traceUpdate('p:panel','X'.charAt(0))}">

but I have tried to use simple quote directly without using charAt(0) tips ... and this work correctly when parameter type is char.

Best solution

<p:panel style="border:none;#{vC.traceUpdate('p:panel','X')}">
schlebe
  • 3,387
  • 5
  • 37
  • 50