javier_fernande
Occasional Observer

How can I show an image from a JSP variable?

Hi everyone,

I'm getting some data from a Query, then I want to show an image that is recorded from a FS_REFERENCE.
The field value is:

<CMS_VALUE name="cs_visual" tag="FS_REFERENCE"><LANG id="§" set="1"><UID>image_name</UID><UIDTYPE>MEDIASTORE_LEAF</UIDTYPE><REMOTE/></LANG></CMS_VALUE>


I've tried to use the UID to get the image putting it into a "CMS_REF(media:", but now I know that it's not possible to use dynamic data in that way.

How can I show the image? Do you have any ideas?

Thank you!

0 Kudos
5 Replies
thmarx
I'm new here

Hi Javier,

I guess you are using dynamic database access to query firstspirit from jsp. could you please provide some code, that would help use to reproduce your problem.

Thorsten

0 Kudos

Hi Thorsten,

Yes, that's what I'm doing.

Here is my code:

<fsi:setSchema schema="FS_DATA">
     <fsi:search resultName="resultServices">
          <fsi:query>
               <QUERY entityType="Services" >
                    <FILTERPARAM parameter="category" datatype="java.lang.Integer" value="<%= reqCategoryId %>"/>
                         
                    <c:if test="${-1 != reqCategoryId}">
                         <EQ attribute="ProductCategoriesList.fs_id" parameter="category" />
                    </c:if>
               </QUERY>
          </fsi:query>
          <fsi:getQueryDetails><c:set var="totalResults" value="<%=totalResults%>"/></fsi:getQueryDetails>     

          <div>
               <c:forEach items="${resultServices}" var="r">
                              <c:set var="pictureServiceEntity" value="${r.visual}" />

                    <c:set var="pictureServiceString1" value="${fn:substringAfter(r.visual, '<UID>')}" />
                    <c:set var="pictureServiceString2" value="${fn:substringBefore(pictureServiceString1, '</UID>')}" />
                    <c:set var="pictureService" value="${pictureServiceString2}" />
     
                         $CMS_SET(pictureService)$<c:out value="${pictureService}" />$CMS_END_SET$                         
                         $CMS_REF(media:pictureService)$               

          
                         </c:forEach>
               </div>
     </fsi:search>
</fsi:setSchema>

<fsi:setSchema schema="FS_DATA">
<fsi:search resultName="resultServices">
<fsi:query>
<QUERY entityType="MarketAccessServices" >
<FILTERPARAM parameter="category" datatype="java.lang.Integer" value="<%= reqCategoryId %>"/>
<FILTERPARAM parameter="region" datatype="java.lang.Integer" value="<%= reqRegionId %>"/>
<FILTERPARAM parameter="country" datatype="java.lang.Integer" value="<%= reqCountryId %>"/>
<FILTERPARAM parameter="mandatory" datatype="java.lang.Integer" value="1"/>
<FILTERPARAM parameter="voluntary" datatype="java.lang.Integer" value="2"/>
<FILTERPARAM parameter="conditional" datatype="java.lang.Integer" value="3"/>
<AND>
<c:if test="${-1 != reqCategoryId}">
<EQ attribute="MASProductCategoriesList.fs_id" parameter="category" />
</c:if>
<c:if test="${-1 != reqRegionId}">
<EQ attribute="TUVRegionsList.fs_id" parameter="region" />
</c:if>
$-- 1-Mandatory 2-Voluntary 3-Conditional --$
<OR>
<c:if test="${-1 != reqMandatory}">
<EQ attribute="obligation" parameter="mandatory" />
</c:if>
<c:if test="${-1 != reqVoluntary}">
<EQ attribute="obligation" parameter="voluntary" />
</c:if>
<c:if test="${-1 != reqConditional}">
<EQ attribute="obligation" parameter="conditional" />
</c:if>
</OR>
</AND>
</QUERY>
</fsi:query>
<fsi:getQueryDetails><c:set var="totalResults" value="<%=totalResults%>"/></fsi:getQueryDetails>
<div id="mas-finder-resultset">
<c:if test="${-1 != reqCategoryId}">
<fsi:setSchema schema="FS_DATA">
<fsi:search resultName="categoryName">
<fsi:query>
<QUERY entityType="MASProductCategories" >
<FILTERPARAM parameter="id" datatype="java.lang.Integer" value="<%= reqCategoryId %>"/>
<EQ attribute="fs_id" parameter="id" />
</QUERY>
</fsi:query>
</fsi:search>
</fsi:setSchema>
<c:forEach varStatus="stat" items="${categoryName}" var="i">
<c:set var="categoryName" value="${i.text_$CMS_VALUE(#global.language.abbreviation)$}" />
</c:forEach>
</c:if>
<c:if test="${-1 != reqRegionId}">
<fsi:setSchema schema="FS_DATA">
<fsi:search resultName="regionName">
<fsi:query>
<QUERY entityType="TUVRegions" >
<FILTERPARAM parameter="id" datatype="java.lang.Integer" value="<%= reqRegionId %>"/>
<EQ attribute="fs_id" parameter="id" />
</QUERY>
</fsi:query>
</fsi:search>
</fsi:setSchema>
<c:forEach varStatus="stat" items="${regionName}" var="i">
<c:set var="countryName" value=" in ${i.text_$CMS_VALUE(#global.language.abbreviation)$}" />
</c:forEach>
</c:if>
<c:choose>
  <c:when test="${(-1 != reqCategoryId || -1 != reqRegionId) && totalResults > 0}">
<p>To sell <c:out value="${categoryName}" /><c:out value="${countryName}" />, you will need:</p>
  </c:when>
  <c:when test="${(-1 != reqCategoryId || -1 != reqRegionId) && totalResults == 0}">
<p>No results for <c:out value="${categoryName}" /><c:out value="${countryName}" />.</p>
  </c:when>
</c:choose>
<div class="" style="background:white">
<c:forEach items="${resultServices}" var="r">
<c:set var="pictureServiceEntity" value="${r.visual}" />
<c:set var="pictureServiceString1" value="${fn:substringAfter(r.visual, '<UID>')}" />
<c:set var="pictureServiceString2" value="${fn:substringBefore(pictureServiceString1, '</UID>')}" />
<c:set var="pictureService" value="${pictureServiceString2}" />
<c:set var="textServiceString1" value="${fn:substringAfter(r.text_$CMS_VALUE(#global.language.abbreviation)$, '<DOM>')}" />
<c:set var="textServiceString2" value="${fn:substringBefore(textServiceString1, '</DOM>')}" />
<c:set var="textService" value="${textServiceString2}" />
<%
String resultEscape = StringEscapeUtils.unescapeHtml((String)pageContext.getAttribute("textService"));
%>
$--CMS_SET(setIdImage)$${r.fs_id}$CMS_END_SET--$
$--CMS_VALUE(image_map[setIdImage.toString.trim])--$
$--CMS_VALUE(image_map.toString)--$
$--<img src="$CMS_REF(image_map[setIdImage.toString.trim])$" />--$
$CMS_SET(pictureService)$<c:out value="${pictureService}" />$CMS_END_SET$
$CMS_SET(titleService)$<c:out value="${r.name_$CMS_VALUE(#global.language.abbreviation)$}" />$CMS_END_SET$
$CMS_SET(textService)$<%= resultEscape %>$CMS_END_SET$
$CMS_RENDER(template:"mas_result",
prm_picture:pictureService,
prm_title:titleService,
prm_text:textService
)$
</c:forEach>
</div>
</div>
</fsi:search>
</fsi:setSche

Thank you!

0 Kudos

Hi Javier,

sorry, but the dynamic database access module does not support medias. there is a feature request for that:  https://community.e-spirit.com/ideas/1108

But there is a workaround: https://community.e-spirit.com/message/5498#5498

Thorsten

Thorsten,

Well.. this is really a pity. Amazing that a system like this can't handle this kind of situation easily :S

Anyway, I'll try with the workaround.

Thanks!

0 Kudos

Hello Javier,

do you need further help or did Thorstens reply already help you? If so, it would be great if you marked the reply as "correct answer" so that other community users find the solution easily. If you have already found a solution by yourself, it would be very kind of you, if you posted it here.

Best regards

Martin

0 Kudos