Get value input text jstl - Spring MVC - spring-mvc

My friends,
I have problem.
I'm working with spring MVC and I put value in:
<input type="hidden" name="projetoid" id="projId"/>
I'd like to get valeu of "projetoid" and pass as argument:
<p><s:message code="modal.projeto.confirma_desativacao" arguments="???" htmlEscape="false"/></p>
Any idea? How can I get this value with JSTL?

There's a little difficulty understanding your question, but I perceived it as you want the value in projId to be passed into the s:message arguments attribute. Here is what I have tested and found working.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
<input type="hidden" name="projetoid" id="projId" value="testing123"/>
<p><s:message id="target" code="modal.projeto.confirma_desativacao" arguments="???" htmlEscape="false"/></p>
<script type='text/javascript'>
$(document).ready(function(){
var hiddenVal = $('#projId').val();
$('#target').attr("arguments", hiddenVal);
console.log('Logged: '+$('#target').attr("arguments"));
});
</script>
</body>
I could see the console.log successfully printed the value of projId.
I used jQuery to do the job. When the document is ready, I passed the value from projId to id:target. If you are trying to pass the value upon form submit, then you have to create a function to transfer the value over upon submitting the form. Hope this helps =)

Related

Can't able to make jquery input mask work

I couldn't for some reason get the jquery input mask plugin to work. I didn't know jquery so any person whom had worked in jquery please reply. here is my testPage.php code
<html>
<head>
<script src="view/script/jquery-2.1.1.js" type="text/javascript"></script>
<script src="view/script/jquery.inputmask.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
jQuery(function ($) {
$("#cnicFieldName").mask("99999-9999999-9");
});
</script>
ID :<input type="text" id="cnicFieldName" /> <br />
</body>
</html>
FYI: Yes I had included both the jquery (latest avalible version) and jquery.inputmask.js from the dist folder i.e. jquery.inputmask-3.x\dist\inputmask\jquery.inputmask.js. (I had downloaded both from jquery.com (both the main jquery file and the input mask plugin)
When I select the input nothing appears in it i.e. underscores etc and it didn't prevent charecter data in it. I am sure I am missing a very minute detail but I couldn't figure out what that is. Thanking you in advance for considering to reply.
You need to call mask after the document is ready. And you are using mask("99999-9999999-9") inlace of inputmask("99999-9999999-9");.
<body>
<script type="text/javascript">
$(document).ready(function(){
$("#cnicFieldName").inputmask("99999-9999999-9");
});
</script>
ID :<input type="text" id="cnicFieldName" /> <br />
</body>
You can refer jquery.inputmask 3.x plugin or check JSFiddle

how to use CORS with OpenCPU

I have just found out about this fantastic project, called OpenCPU. I am currently trying to learn how to use CORS to integrate R in web applications. To do so, I am replicating a simple example, but until now I have been unsuccessful.
I am trying to use the smoothplot function from the stock package and integrate it in an external web-page (https://github.com/opencpu/stocks).
I have already looked at the examples at the OpenCPU web-page and the ones on jsfiddle, but without luck figuring out what I am doing wrong.
Can anyone point me in the direction of my mistake when calling the smootplot function? Or am I missing something completely?
My html and script is as follow
<!DOCTYPE html>
<html lang="en">
<head>
<title>OpenCPU demo app</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- ocpu library -->
<script src="//code.jquery.com/jquery-1.10.2.min.js"> </script>
<script src="//public.opencpu.org/js/opencpu-0.4.js"> </script>
<style>
#plotdiv {
height: 400px;
border: solid gray 1px;
}
</style>
</head>
<body>
<h1>Call R to download data for a specified stock ticket and plotting it</h1>
<b>Ticker</b> <input type="text" value="GOOG" id="ticker">
<button id="submitbutton" type="button">Submit to server!</button> <br><br>
<div id="plotdiv"></div>
<!-- input and recieve output specified using jquery, and RESTful software architectur-->
<script type='text/javascript'>
// location of R function on openCPU server
ocpu.seturl("//public.opencpu.org/ocpu/library/stocks/R")
//call R function: stocks::smoothplot(ticker=ticker)
$("#submitbutton").click(function(){
var ticker = $("#ticker").val();
var req = $("#plotdiv").rplot("smoothplot", {
ticker : ticker,
from : "2013-01-01"
});
req.fail(function(){
alert("R returned an error: " + req.responseText);
});
});
</script>
</body>
</html>
Best regards
As #Jeroen pointed out, change your
<script src="//public.opencpu.org/js/opencpu-0.4.js"> </script>
to
<script src="//public.opencpu.org/js/archive/opencpu-0.4.js"> </script>
and it should work just fine (it did for me).

ASP Calendar date from text field to calendar

Hello guys I tried to do it myself but for this I didn't know what I had to do. So basically what I need to do is create a text field a button and a calendar. So I have done almost everything but I need to make it when a date is typed in the text field and I submit it the calendar updates. so far I only got the date in the text field when clicking on a date but this is not what I need. Any help is appreciated thank you
This isn't really a Classic ASP specific question, what you're really after is a Javascript date picker component. Something like this JQuery Datepicker will do exactly what you're after.
Usage:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker"></p>
</body>
</html>

google maps autocomplete, hook before the display results

Is there any way to put an hook to the even before typed results are displayed ? I want to filter the ones which are not fitting to my need (ie not in the country that I implement).
Here is my current code:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<script src="http://maps.google.com/maps/api/js?sensor=false&libraries=places&language=es&region=MX" type="text/javascript"></script>
<script type="text/javascript">
function hebe(){
var defaultBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(18.2397859708389,-99.876708984375),
new google.maps.LatLng(20.23127464130257,-97.899169921875)
);
var input = document.getElementById('searchTextField');
autocomplete = new google.maps.places.Autocomplete(input);
autocomplete.setBounds(defaultBounds)
}
</script>
</head>
<body onLoad="hebe();">
<input id="searchTextField" type="text" size="50">
</body>
</html>
Possibly componentRestrictions?
componentRestrictions can be used to restrict results to specific groups. Currently, you can use componentRestrictions to filter by country. The country must be passed as as a two character, ISO 3166-1 Alpha-2 compatible country code.
https://developers.google.com/maps/documentation/javascript/places#adding_autocomplete

Populate text box with JavaScript on PageLoad

I have a text box called txtName on my form.
In my page I know I need to place the code in my HEAD tag like so......
<script type='text/javascript' language="javascript">
document.FormName.txtName.value = "Robert";
</script>
But I cant seem to set a value to my textbox txtName with the above code......
That's because your code get executed before the DOM is created.
You can do something like this
window.onload = function() {
document.forms['FormName'].elements['txtName'].value = "Robert";
}
or use JQuery
$(function() {
document.forms['FormName'].elements['txtName'].value = "Robert";
// for a shorter syntax use id
$('#txtNameId').val("Robert");
}
Your script executed before page loaded. Use onload event
Can you set the id on the textbox? Then you can use getElementByID("textboxid"); Selecting by id is faster.
UPDATE:
You need to ensure that the DOM has been load so that your script can locate the element you want to update. One way is:
<body>
<form>
<input id="txtName" name="txtaaaName" type="text" value="notnow"/>
</form>
<script type="text/javascript">
function LoadTextBox(){
document.getElementById("txtName").value = "ready to go";
}
LoadTextBox();
</script>
</body>
An alternative could be where you use onload in the body tag:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
function LoadTextBox(){
document.getElementById("txtName").value = "ready to go";
}
</script>
</head>
<body onload="LoadTextBox">
<form>
<input id="txtName" name="txtaaaName" type="text" value="notnow"/>
</form>
</body>

Resources