Struts2 form rendering- extra space in column - forms

It takes certain height for column or say row when we use which we are not able to remove
pls find code for more info
<td><s:form id="formAutocomplete" action="gridVisualisation"
theme="simple" target="grid123">
<table>
<tr>
<td><s:select id="selectedProfile" name="selectedProfile"
list="profileList" theme="simple"></s:select></td>
<td><sj:autocompleter id="selectedKeyword"
name="selectedKeyword" list="%{keywords}" loadMinimumCount="2"
label="Search" /> <s:hidden id="hiddenField" value=""
name="selectedProfile"></s:hidden> <s:hidden id="StartValueX"
value="" name="StartValueX"></s:hidden> <s:hidden id="EndValueX"
value="" name="EndValueX"></s:hidden> <s:hidden id="DurationType"
value="" name="DurationType"></s:hidden></td>
<td><sj:submit targets="grid123" value="AJAX Submit"
timeout="2500" parentTheme="simple" indicator="indicator"
onBeforeTopics="before" onCompleteTopics="complete"
onErrorTopics="errorState" effect="highlight"
effectOptions="{ color : '#222222' }" effectDuration="3000"
onclick="javascript:setXYGraphVal();" /></td>
</tr>
</table>
</s:form></td>

Related

GetVMImageUrl doesn't work when Overriding

I want to override in a ViewModel the way is showed a picture.
According to the DevelopmentView:
Picture for foto2
<div ng-show="ViewModelRoot.VM_Status.vmEditAlumno_foto2_Visible">
<table>
<thead>
</thead><tbody>
<tr>
<img ng-src="{{StreamingViewModelClient.GetVMImageUrl(ViewModelRoot.Curr_vmEditAlumno(), "foto2")}}" img-responsive class="vmImage" />
</tr><tr>
<input type="file" onchange="angular.element(this).scope().onFileSelect('vmEditAlumno.foto2', angular.element(this).scope().ViewModelRoot.Curr_vmEditAlumno().VMClassId)" id="vmEditAlumno.foto2" ng-show="ViewModelRoot.VM_Status.vmEditAlumno_foto2_Enabled" />
</tr>
</tbody>
</table>
</div>
I set "Content Override" in the column and create a AngularUIOverride tag with value "Foto2Alumno.cshtml".
Not it gets the new file "Foto2Alumno.cshtml", as if I change something in that file it is showed, but the picture from the command GetVMImageUrl
isn't show
What am I missing?
Thanks
It was a problem with double quotes ("). I changed them to single quote (') and now the image is shown.
Wrong:
GetVMImageUrl(ViewModelRoot.Curr_vmEditAlumno(), "foto2")
Right:
GetVMImageUrl(ViewModelRoot.Curr_vmEditAlumno(), 'foto2')

Select an item from a list in JSTL

In the following JSP , i have a list which i am iterating and printing with an additional button
JSP
<form action="servlet">
<table border="2">
<th>Req no</th>
<th>username</th>
<th>Leave Type</th>
<th>No of Days Requested</th>
<th>Status</th>
<th>Approve</th>
<c:forEach var="pro" items="${userRequest}">
<tr>
<td><c:out value="${pro.reqno}"></c:out></td>
<td><c:out value="${pro.user_name}"></c:out></td>
<td><c:out value="${pro.leave_Type}"></c:out></td>
<td><c:out value="${pro.no_of_days}"></c:out></td>
<td><c:out value="${pro.status}"></c:out></td>
<td><input type="submit" value="approve"></td>
<td><input type="hidden" name="approve" value="yes"></td>
<td><input type="hidden" name="reqno" value="${pro.reqno}"></td>
</tr>
</c:forEach>
</table>
</form>
If i click on the approve button in my form , the hidden fields takes the value of all the rows . I need to post reqno from individual row alone (i.e) the row which i click the button. Please suggest me an idea .
Thanks in advance !
You need to change Approve button from 'submit' type to 'button' type.
You remove 'hidden' input in TR.
Sample codes:
<tr>
<td><c:out value="${pro.reqno}"></c:out></td>
<td><c:out value="${pro.user_name}"></c:out></td>
<td><c:out value="${pro.leave_Type}"></c:out></td>
<td><c:out value="${pro.no_of_days}"></c:out></td>
<td><c:out value="${pro.status}"></c:out></td>
<td><input type="button" class="btnApproveReq" data-reqno="${pro.reqno}" value="approve"></td>
</tr>
use jQuery to handle onclick:
<script type="text/javascript">
$(document).ready(function () {
$(".btnApproveReq").click(
function() {
var selectedReqNo = $(this).attr("data-reqno");
var urlToApprove = "/yourApp/req/approve?reqno=" + selectedReqNo;
// CALL AJAX to urlToApprove
// Call this If you want to remove TR after AJAX success
// $(this).parent() --> TD
// $(this).parent().parent() --> TR
$(this).parent().parent().remove();
}
);
});
</script>

How can a submittable online form recognize ( \t ) & ( \n ) delimiters and skip <input>'s when using copy-paste from Excel?

[[UPDATED AGAIN]] And I am sorry if this question gets wordy.
I am a hobby coder, and I am looking for some help with syntax and functionality within javaScript which will allow copied delimiters such as "\t" and "\n" to skip appropriate <input>'s in an online form.
I think I am about 33% there right now (again: hobby coder - self taught wanna be)
<script type="text/javascript">
function splitInput()
{
var x=document.forms["simpleForm02"]["dataInput_0"].value;
var delimiterT = x.split("\t");
var delimiterN = x.split("\n");
for (var i=0;i<delimiterT.length;i++)
if (x.indexOf("\t") >-1)
{
document.getElementById("dataInput_" + i ).value = (delimiterT[i]);
}
else
for (var i=0;i<delimiterN.length;i++)
if (x.indexOf("\n") >-1)
{
document.getElementById("dataInput_" + (i * 3) ).value = (delimiterN[i]);
}
}
</script>
<form name="simpleForm02">
<table>
<tr>
<th>Color</th>
<th>Model</th>
<th>Qty</th>
</tr>
<tr>
<td><input class="colorInput" id="dataInput_0" name="colorInput_row_1" value="" onKeyUp="splitInput()"></td>
<td><input class="modelInput" id="dataInput_1" name="modelInput_row_1" value="" onKeyUp=""></td>
<td><input class="qtyInput" id="dataInput_2" name="qtyInput_row_1" value="" onKeyUp=""></td>
</tr>
<tr>
<td><input class="colorInput" id="dataInput_3" name="colorInput_row_2" value="" onKeyUp=""></td>
<td><input class="modelInput" id="dataInput_4" name="modelInput_row_2" value="" onKeyUp=""></td>
<td><input class="qtyInput" id="dataInput_5" name="qtyInput_row_2" value="" onKeyUp=""></td>
</tr>
<tr>
<td><input class="colorInput" id="dataInput_6" name="colorInput_row_3" value="" onKeyUp=""></td>
<td><input class="modelInput" id="dataInput_7" name="modelInput_row_3" value="" onKeyUp=""></td>
<td><input class="qtyInput" id="dataInput_8" name="qtyInput_row_3" value="" onKeyUp=""></td>
</tr>
</table>
</form>
This code kinda works, in a limited way. If I copy three excel cells aligned side by side, and paste it into <input class="colorInput" id="dataInput_0" name="colorInput_row_1" value="" onKeyUp="splitInput()">, then the script correctly splits and pastes the contents of the three cells across the top three inputs.
However, I obviously have flaws in the script because it doesn't recognize the '\n' delimiter at all. And I also know that I have coding issues with the circumstance: applying the code to all cells relatively, and not just ["dataInput_0"].
And lets presume I had the following data in an Excel sheet:
I am trying to find functionality that if I copied the Excel sample data above, it would overwrite/write the top 6 of the inputs in the sample <form name="simpleForm">.
Sorry to be long winded.
So, this question has been up for about a week, and during that time I have continued to look for ideas and help.
The solution which has presented to finest potential, but not a complete solution is via the code below:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
</head>
<body>
<script>
function splitInput() {
var x = document.forms["simpleForm02"]["dataInput_0"].value;
if (x.indexOf('\t') > 0) {
var delimiterT = x.split('\t');
for (var i = 0; i < delimiterT.length ; i++)
document.getElementById("dataInput_" + i).value = (delimiterT[i]);
}
else
if (x.indexOf('\n') > 0) {
var delimiterN = x.split('\n');
var j = 0;
for (var i = 0; i < delimiterN.length ; i++) {document.getElementById("dataInput_" + j).value = (delimiterN[i]);
j += 4;
}
}
else
return false;
}
function classFocused() {
var d = document.getElementById("dataInput_0");
d.className = d.className + " InFocus";
}
function classBlured() {
var d = document.getElementById("dataInput_0");
d.className = "inputArea";
}
</script>
<form name="simpleForm02">
<table>
<tr>
<th>Color</th>
<th>Model</th>
<th>Qty</th>
<th>Cost</th>
</tr>
<tr>
<td>
<textarea data-id="0" class="inputArea colorInput" id="dataInput_0" name="colorInput_row_1" onFocus="classFocused();" onBlur="classBlured();" onKeyUp="splitInput();"></textarea>
</td>
<td>
<textarea data-id="1" class="inputArea modelInput" id="dataInput_1" name="modelInput_row_1" onkeyup="" ></textarea></td>
<td>
<textarea data-id="2" class="inputArea qtyInput" id="dataInput_2" name="qtyInput_row_1" onkeyup="" ></textarea></textarea></td>
<td>
<textarea data-id="3" class="inputArea costInput" id="dataInput_3" name="costInput_row_1" onkeyup="" ></textarea></td>
</tr>
<tr>
<td>
<textarea data-id="4" class="inputArea colorInput" id="dataInput_4" name="colorInput_row_2" onkeyup="splitInput()" ></textarea></td>
<td>
<textarea data-id="5" class="inputArea modelInput" id="dataInput_5" name="modelInput_row_2" onkeyup="" ></textarea></td>
<td>
<textarea data-id="6" class="inputArea qtyInput" id="dataInput_6" name="qtyInput_row_2" onkeyup="" ></textarea></td>
<td>
<textarea data-id="7" class="inputArea costInput" id="dataInput_7" name="costInput_row_2" onkeyup="" ></textarea></td>
</tr>
<tr>
<td>
<textarea data-id="8" class="inputArea colorInput" id="dataInput_8" name="colorInput_row_3" onkeyup="splitInput()" ></textarea></td>
<td>
<textarea data-id="9" class="inputArea modelInput" id="dataInput_9" name="modelInput_row_3" onkeyup="" ></textarea></td>
<td>
<textarea data-id="10" class="inputArea qtyInput" id="dataInput_10" name="qtyInput_row_3" onkeyup="" ></textarea></td>
<td>
<textarea data-id="11" class="inputArea costInput" id="dataInput_11" name="costInput_row_3" onkeyup="" ></textarea>
</td>
</tr>
</table>
</form>
</body>
</html>
In the above example of the textarea's, if a '\t' delimiter exists then the split is made and the data is spread over the course of the data's inherit length.
Also, in the above example of the text areas, if a '\n' delimiter exists then the split is made and the data is spread over the course of the data's inherit length vertically instead. The statement: "j += 4" is in essence the number of columns you have in the form.
Though I still need for it to work across all text area inputs, not just the identified as ["dataInput_0"]. A jQuery $(this) identifier maybe?
Also, the coding is limited because if you copy and paste cells which have both \t and \n, then the code doesn't work.
But it is a step in the right direction.

ASP.net: How to toggle a checkbox based on a dropdownlist selection

I have a dropdownlist control and it's populated with a list of peoples names from a database. I want to enable a CheckBox control if the user selects a person in the list and disable the checkbox if they select BLANK (also an option in the list).
Here is a portion of my code...
<tr>
<td> <asp:Label ID="lblAssignedTo1" runat="server" Text="Assigned To:"></asp:Label></td>
<td><asp:DropDownList ID="ddlAssignedTo1" runat="server" AppendDataBoundItems="True" DataSourceID="dsAssignedTo" DataTextField="StaffName" DataValueField="StaffID"><asp:ListItem Text="" /></asp:DropDownList></td>
</tr>
<tr>
<td> <asp:Label ID="LabelEmail1" runat="server" Text="Send Email:"></asp:Label>
</td>
<td><asp:CheckBox ID="cbEmail1" runat="server" Checked="true" /></td>
</tr>
The checkbox is a trigger to send an email to the person selected from the list. I want it to default the checkbox to "enabled" if a person is selected from the list to make sure the program I am using is going to send an email later on.
I had a look at http://api.jquery.com/change/ for an example of this, but it's not using a checkbox control, so not sure if it would work. Sorry I am new to jScript.
Thanks in advance
A pure HTML and JavaScript approach would look something like this:
<select id="people">
<option value="">Select One</option>
<option value="person1">Person 1</option>
<option value="person2">Person 2</option>
<option value="person3">Person 3</option>
</select>
<input type="checkbox" name="sendemail" id="sendemail" disabled="disabled" />
$(document).ready(function() {
$('#people').change(function() {
if($(this).val() == '') {
$('#sendemail').attr('disabled', 'disabled');
}
else {
$('#sendemail').removeAttr('disabled');
}
});
});
http://jsfiddle.net/AEXpG/
In terms of your code, just grab the select list and checkbox ClientId and then apply the above jQuery code to them.

jQuery Selecting multiple, different-type, elements in td

Given this table structure:
<table id="tblBranchDetails">
<tr>
<td width="120px">Branch:</td>
<td id="branchName" class="branchData">
<label id="lblBranchName"></label>
<input type="text" id="txtBranchName" class="hideOnLoad editBranchInfo" />
</td>
</tr>
<tr>
<td>Address Line 1:</td>
<td id="branchAddress1" class="branchData">
<label id="lblAddress1"></label>
<input type="text" id="txtAddress1" class="hideOnLoad editBranchInfo" />
</td>
</tr>...
I'm trying to select the label and input in each td so I can clear the label's text and hide the input.
This gives me the text in the label (verified in the console):
$('table#tblBranchDetails tr td:nth-child(2):eq(0)').text();
So I know I can clear the label's text with ".text('')"
Having figured that out, I thought this would give me the value of the input:
$('table#tblBranchDetails tr td:nth-child(2):eq(1)').val()
But it gives me the value of the label in the next td. So obviously I'm using the :nth-child() and :eq() functions wrong.
What's the correct way to do what I'm trying to do?
I was nuking this.
Here's the solution:
$('#btnShowBranchEditBoxes').click(function() {
$('#tblBranchDetails tr').find('label').fadeOut(200);
$('#tblBranchDetails tr').find('.editBranchInfo').delay(200).fadeIn(200);
// Replace the buttons
$('table#tblBranchDetails input#btnShowBranchEditBoxes').fadeOut(200);
$('table#tblBranchDetails input.btnEditBranch').delay(200).fadeIn(200);
});