Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Gerhard Steffek
Search-Container: Code inside "value="<img src='<%=" not processed.
August 23, 2012 3:24 PM

Gerhard Steffek

Rank: New Member

Posts: 4

Join Date: August 15, 2012

Recent Posts

Hello everyone,

my Portlet is supposed to show database values trough a search-container. The point where Im stuck is showing images based on the data in the database.

The following function works fine (convertTrueFalse changes the boolean to the text I want to show based on True or False (like "X" for true and nothing for false)):
2        <liferay-ui:search-container-column-text name="Skype" 
3        value="<%= EntLocalServiceUtil.convertTrueFalse(ent.getSkype()) %>" />

It writes an X in the column when Skype=1 in the database and nothing when =0.

Now I wanted to show just an icon/image, that works too (I took a random image from the skype website):
2    <liferay-ui:search-container-column-text name="Skype"
3    value="<img src=""/>

But when I try to show the image only when the database value is TRUE, it doesnt work:
2        <liferay-ui:search-container-column-text name="Skype"
3        value="<img src='<%=EntLocalServiceUtil.getCommunication(ent, renderRequest) %>'/>"/>

(I get a picture when using the code given as "value" outside of the search container)

getCommunication (I made it as simple as possible when trying to find the error, later it should get some logic based on the ent object):
1    public String getCommunication(Ent val, RenderRequest request){
2        String path = "";
3        return (path);

In the search-column it shows a "missing image"-icon, linking to
and I have no clue why the java doesnt get processed (thats the error, isnt it?). I tried so many things, changing the quotation marks, leaving them away, tried to put the img "outside" of the liferay-search-container-column-text but then it doesnt get shown at all, tried to use liferay-ui:png-image but I failed with everything.

So here is my question: How can I show an image based on the ent-object inside a liferay search-container, to be more specific: Why is the code inside <% method();%> not processed and just seen as plain text?
Amos Fong
RE: Search-Container: Code inside "value="<img src='<%=" not processed.
August 23, 2012 7:47 PM

Amos Fong


Rank: Liferay Legend

Posts: 1898

Join Date: October 7, 2008

Recent Posts

I don't think you can mix expressions with text here. Create a java variable first with the full string and then use the java expression.

2String imgTag = "<img src='" + EntLocalServiceUtil.getCommunication(ent, renderRequest) + "' />";
5<liferay-ui:search-container-column-text name="Skype"
6        value="<%= imgTag %>"/>