get the index of a tal:repeat in another tal:repeat function - plone

As you can see I have 3 lists: Procedur_Headers, Diagnoses and List_Procedur.
Procedur_headers gives the headers of my tabels,
Diagnoses gives the specific id of a procedure and
List_Procedur is a list of lists (query’s) where all the data that I need is contained.
Now what I want to do is to have the index of the Diagnoses page in the
tal:repeat="list_procedur List_Procedur[index]"
that I can get my data in my table.
I already can get the index:
tal:content="python:repeat['diagnoses'].index"
but I can't do this at the place of index.
Does anybody have a solution for something like this?
<table id="tableIngrepen" class="table">
<thead class="header">
<tr>
<th>Code Diagnose vast</th>
<th tal:repeat="procedur_headers Procedur_Headers" tal:content="procedur_headers" > </th>
</tr>
</thead>
<tr tal:repeat="diagnoses Diagnoses">
<td tal:content="python:repeat['diagnoses'].index"></td>
<td ><input type='text' id="dz_code" class="input-mini" value="${diagnoses.code_diagnose}" onchange="voegrijtoe_Ingrepen(this.value,this);logging(this,'Code','2')" placeholder="Code"></input></td> <!-- onfocus="rijencolom($(this).parent().children().index($(this)),$(this).parent().parent().children().index($(this).parent()))" -->
<td colspan="6">
<table id="tableIngrepen" class="table table-hover" style="border-style:none">
<thead class="header">
<tr>
<th tal:repeat="procedur_headers Procedur_Headers" tal:content="procedur_headers" > </th> <!-- style="display:none"-->
</tr>
</thead>
<tr tal:repeat="list_procedur List_Procedur[index]">
<td style="max-width: 60px; word-wrap: break-word" >Uitleg over de Code van deze diagnose in maximaal 200 karakters</td>
<td ><input type='text' id="dz_Datum" class="input-small2" value="${list_procedur.code_diagnose}" onchange="logging(this,'Datum','2');datumvalidate(this)" placeholder="yyyy-mm-dd"></input></td>
<td><input type='text' id="dz_dir" class="input-mini1" onchange="logging(this,'Dir','2')" ></input></td>
<td><input type='text' id="dz_aan" class="input-mini1" onchange="logging(this,'Aan','2')" ></input></td>
<td><input type='text' id="dz_uit" class="input-mini1" onchange="logging(this,'Dz','2')" ></input></td>
</tr>
<tr>
<td style="max-width: 60px; word-wrap: break-word" >Uitleg over de Code van deze diagnose in maximaal 200 karakters</td>
<td ><input type='text' id="dz_Datum" class="input-small2" onchange="logging(this,'Datum','2');datumvalidate(this)" placeholder="yyyy-mm-dd"></input></td>
<td><input type='text' id="dz_dir" class="input-mini1" onchange="logging(this,'Dir','2')" ></input></td>
<td><input type='text' id="dz_aan" class="input-mini1" onchange="logging(this,'Aan','2')" ></input></td>
<td><input type='text' id="dz_uit" class="input-mini1" onchange="logging(this,'Dz','2')" ></input></td>
</tr>
</table>
</td>
</tr>
</table>

The solution is:
<tr tal:repeat="diagnoses Diagnoses"> <div tal:omit-tag="" tal:define="myindex python:repeat['diagnoses'].index"> ..use the myindex.. </div> </tr>

Related

How to send multiple objects from jsp files

I want to send multiple objects from jsp file using commandname in spring form
I have searched on google and explored various sites but found no solutions of this problem
<form:form action="addproductLED"method="post"commandname="addProductLed">
<div align="center">
<h2 class="ledtechdetails">Add Led</h2>
</div>
<div style="margin-top:25px;margin-bottom:25px;">
<table border="0" cellpadding="10" cellspacing="10" class="addledtable">
<tr class="add-led">
<td class="add-led">Product Category :</td>
<td class="add-led">
<select id="productCatId"name="productCatId"class="protechname"onchange="showled('led')" required>
</tr>
<tr class="add-led">
<td class="add-led">Product Name :</td>
<td class="add-led">
<input type="text" name="productName" required class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Product Stock :</td>
<td class="add-led"><input type="number" name="productStock" required class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Product SKU :</td>
<td class="add-led"><input type="text" name="productsku" required class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Product MRP :</td>
<td class="add-led"><input type="number" name="productMrp" required class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Product Price :</td>
<td class="add-led"><input type="number" name="productprize" required class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Product Size :</td>
<td class="add-led"><input type="text" name="productsize" class="protechname"/></td>
</tr>
<!-- another model class configuration -->
<tr class="add-led">
<td class="add-led">Resolution :</td>
<td class="add-led"><input type="text" name="resolution" class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Port :</td>
<td class="add-led">
<input type="text" name="port" class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Wifi Type :</td>
<td class="add-led"><input type="text" name="type" class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Operating System :</td>
<td class="add-led"><input type="text" name="operatingSystem" class="protechname"/></td>
</tr>
I want to get model class object in Spring Controller but I dont know how to send two model class object from one single jsp page
You can transfer multiple objects using commandname separated by semi-colon,
You have to change
<form:form action="addproductLED"method="post"commandname="addProductLed">
to
<form:form action="addproductLED" method="post" commandname="addProductLed,anotherObject" enctype="multipart/form-data">
It will send multiple object.

How to have a struts2 form in a table?

I am trying to have my form in a table but it generates a table and makes it a mess.
the generated table is as following:
<div>
<s:form action="myaction" >
<table border="1">
<tr>
<td><s:textfield name="name" label="Name" /></td>
<td><s:textfield name="family" label="Family" /></td>
<td><s:submit/></td>
</tr>
</table>
</s:form>
</div>
Source code :
<div>
<form id="myaction" name="myaction" action="/application/myaction.action" method="post">
<table class="wwFormTable"> <<<generated table
<table border="1">
<tr>
<td><tr>
<td class="tdLabel"><label for="Search_Name" class="label">Name:</label></td>
<td
><input type="text" name="Name" value="" id="Search_Name"/></td>
</tr>
</td>
<td><tr>
<td class="tdLabel"><label for="Search_Family" class="label">Family:</label></td>
<td
><input type="text" name="Family" value="" id="Search_Family"/></td>
</tr>
</td>
<td><tr>
<td colspan="2"><div align="right"><input type="submit" id="Search_0" value="Submit"/>
</div></td>
</tr>
</td>
</tr>
</table>
</table></form>
Use the "simple" theme if you do not want to use S2's default "xhtml" theme.
You'll lose S2's automatic error reporting. You may wish to consider creating your own theme.
Alternatively, you can use the "simple" theme on individual controls.
See the "Themes and templates" docs to get started.
Try to use any theme in struts form tag
eg:
<s:form action="Courses" theme="css_xhtml">
<table border="0">
<tr>
<td><s:textfield name="courseAbbr" /></td>
</tr>
</table>
</s:form>
May Be you should use this code instead...
<sp:form >
<tr>
<td>
<table>
<sp:textfield name="name"></sp:textfield>
</table>
</td>
<td>
<table>
<sp:textfield name="family"></sp:textfield>
</table>
</td>
<td>
<table>
<sp:submit/>
</table>
</td>
</tr>
</sp:form>

How do I use html decode in my view page?

My engine is Aspx.
I am currently having trouble editing one of my columns(Question Answer) in my table because it has html tags in it. Is there a way I can decode only that specific row/column in the value area?
<form id="updateFreqQuestionsUser" action="<%=Url.Action("SaveFreqQuestionsUser","Prod")%>" method="post">
<table>
<tr>
<td colspan="3" class="tableHeader">Freq Questions User Details <input type ="hidden" value="<%=freqQuestionsUser.freqQuestionsUserId%>" name="freqQuestionsUserId"/> </td>
</tr>
<tr>
<td colspan="2" class="label">Question Description:</td>
<td class="content">
<input type="text" maxlength="2000" name="QuestionDescription" value="<%=freqQuestionsUser.questionDescription%>" />
</td>
</tr>
<tr>
<td colspan="2" class="label">QuestionAnswer:</td>
<td class="content">
<input type="text" maxlength="2000" name="QuestionAnswer" value="<%=freqQuestionsUser.questionAnswer%>" />
</td>
</tr>
<tr>
<td colspan="3" class="tableFooter">
<br />
<a id="freqQuestionsUserUpdateButton" href="#" class="regularButton">Save</a>
Cancel
</td>
</tr>
</table>
Yes, you can do this:
<input type="text" maxlength="2000" name="QuestionAnswer"
value="<%=Server.HtmlDecode(freqQuestionsUser.questionAnswer)%>" />
Reference

How to disable all td tag in jsp using css

I have a form that is in jsp at one condition the user click to view the form. When the form is render the information contain in the form should not be editable all the td should be visible but should not be editable.
for example:-
<table width="600" align="center" >
<tr>
<td class="td_left_b" width="30%">Company Name:</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.companyName}" id="companyName"/></td>
</tr>
<tr>
<td class="td_left_b" width="30%">Hotel Name(Display Name):</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.hotelName}" id="hotelName"/></td>
</tr>
<tr>
<td class="td_left_b" width="30%">Country:</td>
<td width="60%" height="25"><input type="text" size="28" value="" id="country"/></td>
</tr>
<tr>
<td class="td_left_b" width="30%">City:</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.cityName}" id="cityName"/></td></tr>
<tr>
<td class="td_left_b" width="30%">NeighbourhoodName:</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.neighbourhoodName}" id="neighbourhoodName"/></td>
</tr>
<tr>
<td class="td_left_b" width="30%">Street Name:</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.streetName}" id="streetName"/></td>
</tr>
</table>
The above information i am putting through spring MODEL ATTRIBUTE in respective td. i dont want to be editable the information.
Thanks.
You cannot disable Tablecolumns. You have to disable evere input in your table.

Cannot respond to radio button change in partial view

I loaded a partial view containing some radiobuttons on it in my view, but when I try to respond to events from the radio button, through some jquery calls, I can't. Is it impossible to do this, or am I placing the code in the wrong place. I placed the jquery codes in the View and the partial view classes, but neither works. Can anyone help..any advice? Or code samples or links?
Code below:
Sorry...Here's the partial view
#model IEnumerable<Tuda.Models.PriceModel>
<table class="planTable">
<thead>
<tr>
<th></th>
<th scope="col" abbr="Premium">PREMIUM</th>
<th scope="col" abbr="Deluxe">DELUXE</th>
<th scope="col" abbr="Utlmate">ULTIMATE</th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="row" style="font-weight:bold">Select Plan</th>
<td><input type="radio" name="planRadio" value="1"></td>
<td><input type="radio" name="planRadio" value="2"></td>
<td><input type="radio" name="planRadio" value="3"></td>
</tr>
</tfoot>
<tbody>
<tr>
<th scope="row">Library Use (Includes Questions & Answers Only)</th>
<td>Unlimited</td>
<td>Unlimited</td>
<td>Unlimited</td>
</tr>
<tr>
<th scope="row">Interview Tips & Guides</th>
<td><span ><img src="../../Images/check0.png" /></span></td>
<td><span ><img src="../../Images/check0.png" /></span></td>
<td><span ><img src="../../Images/check0.png" /></span></td>
</tr>
<tr>
<th scope="row">Problem Areas Detection</th>
<td><span ><img src="../../Images/check0.png" /></span></td>
<td><span ><img src="../../Images/check0.png" /></span></td>
<td><span ><img src="../../Images/check0.png" /></span></td>
</tr>
<tr>
<th scope="row">Relevant Concepts & Terminology</th>
<td> - </td>
<td> - </td>
<td><span ><img src="../../Images/check0.png" /></span></td>
</tr>
<tr>
<th scope="row">User Recommended</th>
<td></td>
<td><span><img src="../../Images/check0.png" /></span></td>
<td><span><img src="../../Images/check0.png" /></span></td>
</tr>
<tr>
<th scope="row">Validity</th>
<td>1 Month</td>
<td>3 Months</td>
<td>12 Months</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
$(document).ready(function () {
$("input[name='planRadio']").change(function(){
var planse = $("input[name='planRadio']:checked").val();
$.get('#Url.Action(MVC.Account.AddToCartPartial())',
{ id: planse }, function (data) {
$('#plan').html('<p><strong>Adding to cart...</strong> <img src="#Url.Content("~/images/ajax-loader1.gif")" width="54" height="55" /></p>');
$("#plan").html(data);
});
});
</script>
The call to the controller isn't made
$(":radio").live("click", function () {
var inputValue = $('input:radio:checked').val();
});
or to keep the value of the selected Radiobutton on to hidden field
<input type="radio" id="SelectedPlanType" rel="1" name="Plan1" value='1' onClick="document.getElementById('hiddenfield').value=this.value" checked="checked">
<input type="hidden" name="SelectedPlanType" value="" id="hiddenfield" />

Resources