Spring Freemarker Form Bind : Problem with Exponent Value - spring

I have Spring bind form with freemarker. But large number show Exponent value. How to show value without Exponent.
For small numeber...
<#spring.formInput 'CaseMaster.year' 'placeholder="e.g. 2013" ' 'number'/>
For large number...
<#spring.formInput 'CaseMaster.suitValue' 'placeholder="e.g. Suit Value" ' />
HTML View:
I wnat to show value like 80000000 or 80000000.00 or like 8,00,00,000.00 in the second field.

I've dug down into the macro and it looks like you have no control over the formatting to the populated value. Perhaps there's a more elegant solution, but at this point, you might try creating your own macro that gives you formatting control. (This is untested.)
<#macro numberInput path attributes="">
<#spring.bind path/>
<input type="text"
id="${status.expression?replace('[','')?replace(']','')}"
name="${status.expression}" value="status.value?c" ${attributes}<#closeTag/>
</#macro>
You would call it like this:
<#numberInput 'CaseMaster.suitValue' 'placeholder="e.g. Suit Value" ' />

Related

ASP Classic : Put a "variable" in a "Request.Form()"

I have a form that will send an array of data to an ASP page.
Let's say this array is called "matrix".
Usually, on the ASP receiving the form, I will write this out to retrieve the form inputs from the array "matrix".
Request.Form("matrix[]")(i) where i = 1, 2, 3 which are the elements in the array.
Let's say I want to do make a variable like this
a="matrix"
and I want to use this variable a and put it into the request form, instead of writing "matrix", so that it would look something like this
Request.Form(a[])(i)
How can it be done? For now, all my attempts are showing blank. e.g. when I try to make them appear on the page with response.write, nothing shows up.
Please help me or let me know if it cannot be done, I've been spending hours on this.
Request.Form("matrix[]") is taking a string value of "matrix[]" not an array of strings called "matrix".
So you need to do either
a = "matrix[]"
Request.Form(a)(i)
or
a = "matrix"
Request.Form(a & "[]")(i)
Unlike PHP which requires adding square brackets, in classic ASP you just have to give the same name to the elements you want to be combined into an array.
The HTML should be:
<input type="text" name="matrix" />
<input type="text" name="matrix" />
<input type="text" name="matrix" />
Then you can iterate over the submitted values like this:
For x=1 To Request.Form("matrix").Count
Response.Write("Value of matrix #" & CStr(x) & "is: " & Request.Form("matrix").Item(x))
Next
Note that all elements are included, even if user left them empty.

filter_input behavior for integer input tag name

I have form inputs that have their name attribute in Integer like below
<input type="hidden" name="100351312" value="test" />
If I use
echo filter_input( INPUT_POST, '100351312' )
It returns NULL
Whereas
echo $_POST['100351312'] prints the value correctly.
filter_input really needs three inputs; the type, the variable (both of which you have) and the filter, which you don't have. Here are some types of filters: http://php.net/manual/en/filter.filters.php
That said, if you're using WordPress you can almost always find a WordPress helper function you can use instead of filter_input()

Set min value for numeric textbox in Kendo ui template

I need to prevent negative values in Kendo numeric textbox template as below:
<input type="text" data-type="number" data-format="n0" name="SnoozeLength" data-bind="value:snoozeLength" data-role="numerictextbox" />
is there any attributes which i can use line "min-value= 0"
Try with the following:
http://docs.telerik.com/kendo-ui/api/web/numerictextbox#configuration-min
You can specify min configuration for your numerictextbox.
Best Regards,

Add spring macro as parameter to Freemarker macro

I have the code snippet below, and want to give the output from <#spring.message "name"/> as paraneter to the macro (the placeholder parameter).
Providing it directly as I tried doing below didnt't work, anyone knows how I should do it?
<td class="rightCell"><b><#spring.message "name"/>:</b></td>
<td class="leftCell"><#createUserInputItemModifiedv2 "name", "name", "text", #spring.message "name" /></td>
<#macro createUserInputItemModifiedv2 attributeName, errorMessageName, inputType, placeholder>
<input class="edit" type="${inputType}" id="${attributeName}" name="${attributeName}" placeholder="${placeholder}" value="${user[attributeName]!}"/><br/>
<#if validationErrors?? && validationErrors[attributeName]??>
<div class="errorMessage" id="${errorMessageName}Error">
${validationErrors[attributeName]!}
</div>
</#if>
</#macro>
That's because spring.message should also be a FreeMarker function, not just a FreeMarker macro. Macros has no return value (they might directly print to the output writer as a side-effect) so you can't call them where an expression is expected. Anyway... how to work this around right now. Looking at the source code of Spring, maybe this will work:
<#function message code><#return springMacroRequestContext.getMessage(code)></#function>
You could create a utils.ftl or something, (auto-)#import it as u, and then you can do <#createUserInputItemModifiedv2 ..., u.message("name")> in your templates. (Actually, it could be made more convenient, so that you can just write msg.name or like, but let's not go into that here.)
However, I'm not sure if there's any backward compatibility guarantee regarding springMacroRequestContext or its content. So ultimately this should be fixed in Spring.

Validating input type number in html5

I want to restrict entry of input onto a field of type number such that input cannot be outside range of min-max specified in the html.
input type = "number" min = "1" max = "5"
Is there a way of outputting the number field without the text box and i would rather not use
"input type = range"
as slider does not show value currently selected
Please help.
Thanks.
Based on what you said, I suggest using a simple input text field and check it's value validity on submission via JavaScript (as #Kush mentions above). You could also check it as the user types, or moves focus away from that field.
<form>
Only 1 to 100 <input type="text" name="number" pattern="\d{1,2}(?!\d)|100" title="one to hundreed only">
<input type="submit">
</form>

Resources