Condition checking inside a Display tag - conditional-statements

I am displaying a student list(Name ,Mark, Result) using display tag in my struts 2 application.
if student scored more than 80 i need to display the entire row in green color else i need to display it
in red color .Below is my scenario , i am not familiar with display tag, please help me to solve this issue.
<display:table name="studentList" id = "student" cellspacing="1px" class="center">
<display:caption class="caption"><b>Student Mark List</b></display:caption>
if(mark>=80)
{
<display:column title="Student Name" property="name" class="green"> </display:column>
<display:column title="Student Mark" property="mark" class="green"></display:column>
<display:column title="Student Result" property="result" class="green"> </display:column>
}
else
{
<display:column title="Student Name" property="name" class="red"> </display:column>
<display:column title="Student Mark" property="mark" class="red"></display:column>
<display:column title="Student Result" property="result" class="red"> </display:column>
}
Thanks in advance.

I added this taglib at the beginning of my jsp
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
and i added below code
<display:table name="studentList" id = "student" cellspacing="1px" class="center">
<display:caption class="caption"><b>Student Mark List</b></display:caption>
<c:choose>
<c:when test="${mark>='80'}">
<c:set var="css" value="tableColumnGreen"/>
</c:when>
<c:otherwise>
<c:set var="css" value="tableColumnRed"/>
</c:otherwise>
</c:choose>
<display:column title="Student Name" property="name" class="${css}"> </display:column>
<display:column title="Student Mark" property="mark" class="${css}"></display:column>
<display:column title="Student Result" property="result" class="${css}"> </display:column>
This helped me.Thanks for everyone.

Related

How to enable translation of the content of just one field/div in php7?

I am trying to figure out how to enable users to translate the returned content of one field, such as a textarea.
I do not propose to use api's that would translate the whole of the site on click, but just one field or division.
To do that, I have stumbled upon a free widget from gTranslate that could do the job nicely. However, I cannot get it to work for my intended 'just one field' purpose.
I have tried to wrap this widget in an iframe, but still no joy [with my limited php knowledge.]
For this scenario, you can assume that I have a simple crud application that has the usual view/edit/delete routines on the index page. The table has just a few columns in it such as first_name, last_name and so on and a column called comment, which is the text area that I wish to translate. For this, you may assume any text field such as a blog, description, etc.
When View pressed, I fire up 'detail_view.php' which just presents the first name and the comment fields of that record. It is on this page that I wish to have the comment field to get translated. So to this end I thought I would use an iframe. The source of the iframe is a secondary page called 'details_translate_include.php.' It is in this page that I have placed the widget so that the user could select the language by pressing the relevant icon given from that widget.
But It does not work. The data does not get populated and the widget is outside of the iframe.
So, can I ask for your help please?
NB.: This approach may not be the ideal solution to get this going. So, if you are aware of an alternative solution I would be more than happy to listen to.
A. In my 'detail_view.php' I have:
<!-- /.row -->
<div class="col-lg-12">
<div class="col-lg-6">
<form role="form" method="post" action="index.php">
<div class="form-group">
<label>First name:</label>
<input class="form-control" placeholder="First Name" name="firstname" value="<?php echo $xx; ?>">
</div>
<div class="form-group">
<label>Comment:</label>
<textarea class="form-control" rows="3" name="comment"><?php echo $yy; ?></textarea>
</div>
<div class="">
<label>Comment: [repeated here to get the translation working]</label>
<iframe src="details_translate_include.php" width='790' height='250' frameborder='0' scrolling='no' marginheight='0' marginwidth='0'class="bordered-box"></iframe>
</div>
<button type="submit" class="btn btn-default">Return to main menu</button>
</form>
B. In my 'details_translate_include.php' I have:
<?php
include('connection.php');
?>
<?php
if( isset( $_GET['recID'] )){
$yy=$_GET['comment'];
echo $yy;
}
?>
<div>
<textarea name="comment"><?php echo $yy; ?></textarea>
</div>
The output looks like this:
output error image
However, I would like to get the data returned and the widget to be inside of that division.
C. the content of the translate widget [which is freeware] is given below:
<!-- GTranslate: https://gtranslate.io/ -->
<img src="//gtranslate.net/flags/blank.png" height="16" width="16" alt="English" /><img src="//gtranslate.net/flags/blank.png" height="16" width="16" alt="French" /><img src="//gtranslate.net/flags/blank.png" height="16" width="16" alt="German" /><img src="//gtranslate.net/flags/blank.png" height="16" width="16" alt="Italian" /><img src="//gtranslate.net/flags/blank.png" height="16" width="16" alt="Persian" /><img src="//gtranslate.net/flags/blank.png" height="16" width="16" alt="Portuguese" /><img src="//gtranslate.net/flags/blank.png" height="16" width="16" alt="Russian" /><img src="//gtranslate.net/flags/blank.png" height="16" width="16" alt="Spanish" /><img src="//gtranslate.net/flags/blank.png" height="16" width="16" alt="Welsh" />
<style type="text/css">
<!--
a.gflag {vertical-align:middle;font-size:16px;padding:1px 0;background-repeat:no-repeat;background-image:url(//gtranslate.net/flags/16.png);}
a.gflag img {border:0;}
a.gflag:hover {background-image:url(//gtranslate.net/flags/16a.png);}
#goog-gt-tt {display:none !important;}
.goog-te-banner-frame {display:none !important;}
.goog-te-menu-value:hover {text-decoration:none !important;}
body {top:0 !important;}
#google_translate_element2 {display:none!important;}
-->
</style>
<br /><select onchange="doGTranslate(this);"><option value="">Select Language</option><option value="en|ar">Arabic</option><option value="en|eu">Basque</option><option value="en|ca">Catalan</option><option value="en|zh-CN">Chinese (Simplified)</option><option value="en|zh-TW">Chinese (Traditional)</option><option value="en|da">Danish</option><option value="en|nl">Dutch</option><option value="en|en">English</option><option value="en|fi">Finnish</option><option value="en|fr">French</option><option value="en|de">German</option><option value="en|el">Greek</option><option value="en|hi">Hindi</option><option value="en|it">Italian</option><option value="en|no">Norwegian</option><option value="en|fa">Persian</option><option value="en|pl">Polish</option><option value="en|pt">Portuguese</option><option value="en|ru">Russian</option><option value="en|es">Spanish</option><option value="en|sv">Swedish</option><option value="en|tr">Turkish</option><option value="en|cy">Welsh</option></select><div id="google_translate_element2"></div>
<script type="text/javascript">
function googleTranslateElementInit2() {new google.translate.TranslateElement({pageLanguage: 'en',autoDisplay: false}, 'google_translate_element2');}
</script><script type="text/javascript" src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit2"></script>
<script type="text/javascript">
/* <![CDATA[ */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('6 7(a,b){n{4(2.9){3 c=2.9("o");c.p(b,f,f);a.q(c)}g{3 c=2.r();a.s(\'t\'+b,c)}}u(e){}}6 h(a){4(a.8)a=a.8;4(a==\'\')v;3 b=a.w(\'|\')[1];3 c;3 d=2.x(\'y\');z(3 i=0;i<d.5;i++)4(d[i].A==\'B-C-D\')c=d[i];4(2.j(\'k\')==E||2.j(\'k\').l.5==0||c.5==0||c.l.5==0){F(6(){h(a)},G)}g{c.8=b;7(c,\'m\');7(c,\'m\')}}',43,43,'||document|var|if|length|function|GTranslateFireEvent|value|createEvent||||||true|else|doGTranslate||getElementById|google_translate_element2|innerHTML|change|try|HTMLEvents|initEvent|dispatchEvent|createEventObject|fireEvent|on|catch|return|split|getElementsByTagName|select|for|className|goog|te|combo|null|setTimeout|500'.split('|'),0,{}))
/* ]]> */
</script>

struts2 if condition with property or tiles-attribute doesnt work

i have problems with my if condition using struts 2.
I have a tiles-definition using a put-list-attribute with list-attributes as menuitems.
In my menu.jsp i iterate over the put-list to render all my menuitems.
Now i try to check if the value of my item contains a special character.
Here is my code:
tiles.xml
<definition name="start.menu" template="/WEB-INF/menu.jsp" >
<put-attribute name="title" value="Hauptmenu" />
<put-list-attribute name="webThemes" >
<add-list-attribute>
<add-attribute value="Test" id="name"/>
<add-attribute value="atest" />
</add-list-attribute>
<add-list-attribute>
<add-attribute value="System Test"/>
<add-attribute value="test" />
</add-list-attribute>
</put-list-attribute>
</definition>
menu.jsp
<%# taglib prefix="s" uri="/struts-tags" %>
<%# taglib uri="/tiles-jsp" prefix="tiles" %>
<%# taglib uri="/tiles-extras-jsp" prefix="tilesx" %>
<%-- Push tiles attributes in page context --%>
<tiles:importAttribute />
<tilesx:useAttribute id="list" name="webThemes" classname="java.util.List" />
<table class="menu" border="0px" width="100%" cellspacing="0px" cellpadding="0px" >
<s:iterator value="#attr.webThemes" var="item">
<s:if test="%{#item.value[1].contains('a')}">
<s:set var="link" value="111"/>
</s:if>
<s:else>
<s:set var="link" value="#item.value[1]"/>
</s:else>
<tr>
<td valign="top" >
<font size="-1">
<a href="<s:property value="#link"/>"
class="menu">
<s:property value="#item.value[0]" />
<s:property value="#item.value[1]" />
</a>
</font>
</td>
</tr>
</s:iterator>
But the condition is always false.
I tried different approaches but nothing worked:
<s:if test="%{#item.value[1].contains('a')}">
<s:if test="#item.value[1].contains('a')">
<s:if test='%{#item.value[1].contains("a")}'>
<s:set var="itemvalue" value="#item.value[1]"/>
<s:property value="itemvalue"/>
<s:if test='%{#itemvalue.contains("a")}'>
<s:if test='#itemvalue.contains("a")'>
<s:if test='%{#item.value[1] == "atest"}'>
So how can i get the condition working? What am i doing wrong?
Thanks!!!
Ok... i tried 2 days until i posted my question.
but after posting a found a working solution in an hour...:
<s:if test='(#item.value[1].value).startsWith("a")'>

How to use KendoDatePicker within x-kendo-template in .NET Core

I have a popup editor template working for when I want to add/edit a row in my Kendo grid and it is bound to the model's properties. The issue is that I am unable to get Kendo widgets (e.g. datepicker or dropdownlist) to generate inside the kendo-template (primarily wanting to use taghelpers). Nor have I been able to use jQuery to convert inputs into kendo widgets on $(document).ready(). How can I do this?
My grid:
<kendo-grid name="accountsGrid" height="500" on-detail-init="onDetailInit">
<datasource type="DataSourceTagHelperType.Ajax" page-size="10">
<transport>
<read url="?handler=Accounts&id=#Model.Id" data="getAntiForgeryKeyValue" type="POST" />
<create url="?handler=CreateAccount&id=#Model.Id" data="getAntiForgeryKeyValue" type="POST" />
<update url="?handler=EditAccount&id=#Model.Id" data="getAntiForgeryKeyValue" type="POST" />
</transport>
<schema>
<model id="AccountId">
<fields>
<field name="LastUpdateDate" type="Date"></field>
</fields>
</model>
</schema>
</datasource>
<columns>
<column field="Id" hidden="true" />
<column field="AccountName"
title="Account Name"
header-html-attributes='HeaderHtmlAttribute(title:"Account Name")' />
<column field="LastUpdateDate"
title="Last Updated"
format="{0:MMMM dd, yyyy}"
header-html-attributes='HeaderHtmlAttribute(title:"Last Updated")' />
<column title="Actions"
header-html-attributes='HeaderHtmlAttribute(title:"Actions")'
html-attributes='new Dictionary<string, object> {["class"] = "center-cell" }'>
<commands>
<column-command name="edit" />
</commands>
</column>
</columns>
<toolbar>
<toolbar-button name="create" template="getTelerikButton('Add')" />
</toolbar>
<editable mode="popup" template-id="accountEditorTemplate" />
<pageable button-count="5" refresh="true" page-sizes="new int[] { 5, 10, 20 }">
</pageable>
<scrollable enabled="true" />
My Editor Template:
<script id="accountEditorTemplate" type="text/x-kendo-template">
<div class="row editor-padding">
#*Account Details*#
<div class="col-md-6 col-xs-12">
<h5 class="editorTemplateHeader">Account Details</h5>
<div class="k-edit-label">
<label for="AccountName">Account Name</label>
</div>
<div class="k-edit-field">
<input required type="text" class="k-input k-textbox" name="AccountName" validationmessage="Account Name is required" maxlength="8" />
</div>
<div class="k-edit-label">
<label for="Description">Description</label>
</div>
<div class="k-edit-field">
<input type="text" class="k-input k-textbox" name="Description" maxlength="100" />
</div>
<div class="k-edit-label">
<label for="ExpirationDate">Expiration Date</label>
</div>
<div class="k-edit-field">
#*I would like to do this, but nothing appears*#
<kendo-datepicker name="ExpirationDate"></kendo-datepicker>
</div>
</div>
</div>
I resolved the problem. It involved using data- syntax. Below is the solution:
<div class="k-edit-field">
<input required type="text"
name="ExpirationDate"
data-type="date"
data-bind="value:ExpirationDate"
data-role="datepicker"
validationmessage="Expiration Date is required" />
</div>

Images are not displaying in asp.net webforms

I have image links of a website's images stored in my DB but when I show them on my asp page using repeater or data list which im building, it shows some where pics and somewhere just boxes and no
image, can anyone help me?
here is my datalist code to show products but some images are being shown and some are like broken icons and empty box having no image, and i have image links of a website which i am displaying in
data list and i have checked all links as well on web they work perfectly fine but don't show anything in my data list web form,is this a styling issue or binding?
code of Data list is given below
<div style=" border:inset; margin-left:100px; display:inline-block;">
<asp:DataList ID="DataList1" runat="server" RepeatColumns="5" RepeatDirection="Horizontal">
<ItemTemplate>
<div class="span4" style="display:inline-block; border-top:1px; background-color:none;width:190px; height:440px; border:solid; border-width:1px; border-spacing:2px 4px; border-bottom:inset; border-top-width:1px;" runat="server"><br />
<div class="products" style="height:430px; width:189x; border:inset;border-style:none;border-spacing:2px 4px;">
<asp:Image ID="ImgId" runat="server" style=" height:160px; width:160px;" ImageUrl='<%#(DataBinder.Eval(Container.DataItem,"ImageLink")) %>' /> <br />
<h3 class="title" style="font-family:Pristina;font-size:medium;height:30px; margin-bottom:-15px;"> <b><%# Eval("Name") %></b><br /><br /><br /></h3>
<br />
<p class="price" style="font-family:Pristina;font-size:medium; height:30px;padding-top:40px; "><b>Price</b> <%# Eval("Price") %> <br /><br /><br /><br /><br /></p><br />
<br />
<b style="margin-bottom:-20px">www.shophive.com</b>
</div>
</div>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Top"/>
</asp:DataList>
</div>

Rails Link_to image tag isnt retrieving image from database

I'm brand new to rails (and coding in general) so I've a quick question on retrieving images from a database
Running rails 3.2.8
I have a list of products, code, description, price and product_image in the database, The product images is stored as 123.jpg in the database and the image itself is stored in app/assets/images folder
In my view I have the following code
<div class="center_content">
<div class="center_title_bar">Latest Products</div>
<% #camera_catalogues.each do |camera_catalogue| %>
<div class="prod_box">
<div class="top_prod_box"></div>
<div class="center_prod_box">
<div class="product_title"><%= camera_catalogue.model_description %></div>
<div class="product_img"><%= link_to (image_tag camera_catalogue.product_image),camera_catalogue %></div>
<div class="prod_price"><span class="reduce">350$</span> <span class="price"><%=number_to_currency(camera_catalogue.price, :unit =>"€")%> </span></div>
</div>
<div class="bottom_prod_box"></div>
<div class="prod_details_tab">
<img src="assest/cart.gif" alt="" title="" border="0" class="left_bt" />
<img src="assest/favs.gif" alt="" title="" border="0" class="left_bt" />
<img src="assets/favorites.gif" alt="" title="" border="0" class="left_bt" />
details
</div>
</div>
Everything displays correctly except that the image is not retrieved from the database
which is this line
<div class="product_img"><%= link_to (image_tag camera_catalogue.product_image),camera_catalogue %></div>
Does the image in the database need to be saved with a different url. i.e. instead of 123.jpg it is saved as assets/123.jpg
or is there some other error in my code.
Help/advice greatly appreciated :)
Use it like this
<div class="product_img"><%= link_to (image_tag (camera_catalogue.product_image)),camera_catalogue %></div>
I guess it will work for you. You need not use 'assests/image_name'