Reputation: 31637
I am creating web application where I have below code.
<p:commandButton ajax="false"
style="#{patentInfo.photoType.contains('application')?
'visibility:visible;width:200px;height:200px;
background-image: url(DisplayImage?mainID=tempo1&id=#{patentInfo.photoType});
background-repeat: no-repeat;background-size: 100% 100%;'
:
'visibility:hidden;width:2px;height:2px;'}">
I am setting background image where I am using Java class as DisplayImage
and passing parameter to those as mainID=tempo1&id=#{patentInfo.photoType}
. In java, I am printing mainID
& id
for testing purpose.
DipalyImage.java
String mainID = request.getParameter("mainID");
String id = request.getParameter("id");
System.out.println("mainID=="+mainID+", id=="+id);
patentInfo.photoType
will hold data as application/pdf
The problem is at background image parameters that I am passing.
When I use background-image: url(DisplayImage?mainID=tempo1&id=#{patentInfo.photoType});
& print mainID
& id
I get values as below.
mainID=temp1
& id=
I don't get anything for id.....
When I use background-image: url(DisplayImage?mainID=tempo1&id=patentInfo.photoType);
& print mainID
& id
I get values as below.
mainID=temp1
& id=patentInfo.photoType
What I am doing wrong here?
I am expecting output as mainID=temp1
& id=application/pdf
Upvotes: 0
Views: 95
Reputation: 15240
The problem is that you have #{ ... #{} ...}
in your el.
Try something like this:
<p:commandButton ajax="false" style="#{patentInfo.photoType.contains('application')?'visibility:visible;width:200px;height:200px;background-image: url(DisplayImage?mainID=tempo1&id='.concat(patentInfo.photoType).concat(';background-repeat: no-repeat;background-size: 100% 100%;'):'visibility:hidden;width:2px;height:2px;'}">
Upvotes: 1