0

There are many questions based on the heading I have choosed. But none of them solve my problem.

I am using JSF 1.2 (I have to. No other choice). I have an iframe. Now I cannot use EL Expressions in iframe because I get errors:

<iframe src="#{page.pageClicked}"></iframe>

gives an error

#{...} is not allowed in template text

I understand the reason. IFrames are not part of JSF 1.2 standard. That is why JSF does not parse iframes and gives the error. And this is not just for iframes. Any tag that is not supported, throws this error.

Now my question is that to evaluate the expression on the src attribute, what are the workarounds I can do?

This is a possible workaround, but cannot be applied on my case: how can I create variable in JSF to use thro' JSP tag

Community
  • 1
  • 1
Rash
  • 7,677
  • 1
  • 53
  • 74

2 Answers2

0

You could create it using javascript

<script>
//<![CDATA[
    function makeFrame() { 
       ifrm = document.createElement("IFRAME"); 
       ifrm.setAttribute("src", "#{page.pageClicked}"); 
       ifrm.style.width = 640+"px"; 
       ifrm.style.height = 480+"px"; 
       document.body.appendChild(ifrm); 
    } 
//]]>
</script> 
DaveB
  • 2,953
  • 7
  • 38
  • 60
  • Hi. I know I can google this. But I thought this would be faster. Can I use JSF selector #{} in Javascript like you have used in this line - ifrm.setAttribute("src", "#{page.pageClicked}"); – Rash May 20 '14 at 18:35
  • Yes you can as long as the code above is added in the .xhtml page – DaveB May 20 '14 at 20:56
  • Oh thats the thing. I have jsp pages. Can't use xhtml pages. Any workaround for jsp pages ? – Rash May 20 '14 at 21:49
  • Ok, I have never used JSP before, but I think it should still work ok – DaveB May 21 '14 at 06:27
  • Hmm are you actually calling the JS function somewhere ie. makeFrame() ? – DaveB May 21 '14 at 19:54
  • my exact code was some-text. And I have declared your JS on the start of my body. The error was plainly saying that the #{} was in an invalid place. So I am pretty sure that I can't use JSF 1.2 tags in JSP pages. Had it been JSF 2 or above, the #{} tags would work anywhere. – Rash May 21 '14 at 21:03
  • Have you looked at f:verbatim? I think this is relevent to JSP http://stackoverflow.com/questions/2020610/mix-html-and-jsf-in-a-jsf-subview – DaveB May 21 '14 at 21:24
0

I´ve tried a lot and discovered that the outputText just print the value, so try this....

< img src="< h:outputText value="upload/veiculos/#{item.nome}"/ >" / >
HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
  • I do not have my JSF 1.2 setup anymore. Are you sure this will work in JSF 1.2. Having JSF elements as values of HTML attributes does not seems something that should be allowed. Is this a bug because of which u are able to do this ? – Rash Aug 13 '15 at 11:06