ZK binding string value to datebox - binding

I have created a Listbox in which one column can contain different components like Combobox, Datebox, Decimal box etc. In One column I have to display Datebox or Decimalbox on some condition so i bind Datebox and Decimalbox inside this column with String value. I am getting exception when I bind string value to datebox and try to enter the date using popup calender.
<datebox value="#bind(data.prodValue)" width="250px"></datebox>
private String prodValue;
prodValue is of String type.When I enter the date in Datebox, I am getting exception.
Can anybody tell me how to use Datebox with string binding value?

you can create customize datebox where datatype String and Timestamp condition wize .
just set flag type="String/Timestamp"
find this class here just extend in new customize class override setValue method and modify getValue method

datebox use java.util.Date
if you bind #bind(data.prodValue) will be invoked getProdValue() method

Related

Umbraco Form - Remove time from Datepicker date in email

I have a form that contains a Datepicker and in the email that is sent on submission the date is formatted with a time.
How do I remove the time from the date?
Thanks
You can either change the property to just Date, without the time element, or you can use ToString() method for the DateTime within C#:
https://msdn.microsoft.com/en-us/library/zdtaw1bw(v=vs.110).aspx
The format without time would look something like this:
yourDate.ToString("DD/MM/YYYY");

Binding a DateTime to a date input field with Polymer

What's the best way to do that?
When i bind the value of the input element to my DateTime instance, a String is returned:
<input value="{{myDate}}" type="date">
Is there a specific attribute to bind the input to a DateTime instance?
Or should i use a filter?
[EDIT]
here is my working filter (only works with "date" input type):
https://gist.github.com/Vloz/10553552
input elements don't provide an attribute that provides the typed value of the input. You'll need to provide a custom handler that parses the String value and updates your element's DateTime typed attribute.
e.g.
<input type="date" value="{{dateString}}">
...
// inside the element's script...
date: null, // the DateTime typed attribute
// this handler automatically works
dateStringChanged: function(oldValue, newValue) {
this.date = DateTime.parse(newValue); // how about some error handling too?
},

How can I set the format of the JQuery-UI date picker custom binding in KnockoutJS ?

I'm trying to bind an HTML input element with a ISO 8601 formatted date and that needs to show up in the 'dd/mm/yyyy' format.
How can I specify that format when the date picker is a custom binding in KnockoutJS ?
If you have the correct binding handler for integrating JQuery DatePicker into KnockoutJS, all options should be put inside a "datepickerOptions" binding like this:
<span data-bind="datepicker: myDate,
datepickerOptions: { 'dateFormat': 'dd/mm/yy' }"></span>
Additionally, if you are to use this formatting at multiple places, you may want to think about putting this date format string inside an observable property in your view model, which you could then use like this:
<span data-bind="datepicker: myDate,
datepickerOptions: { 'dateFormat': $root.config.dateFormat }"></span>
... which means that the format string is bound in the config.dateFormat property starting from the root.

How to get the selected text from a system.web.mvc.selectlist

I have a system.web.mvc.selectlist when I use .selectedvalue it gives me the value as expected however I use an int ID as the value and would like to get the display text instead.
Update
I've created a selectlist and I'd like to retrieve the selected text on the next line of code. I.e.
SelectList sl = new SelectList(items, "id", "name", 10);
String txt= sl.selectedvalue.text;
That last line is where I am stuck. I'm looking to get the name field for the item with id 10. Ideally without looking up in the db as I want a generic function I can use on all select lists.
I don't think this is possible since the text isn't passed back to the server in a post, only the value is. I can think of two ways to get it though:
Query the database with the value to get the text.
Set the text in a hidden field on the client side before posting the
form. You can do this with jQuery for example.

String[] vs Integer[] in Struts2 action attribute

I am new t struts2. i built one page, that shows list of employees. I can seach the employes based on his name by applying filter criteria and click on find button. At the same time, i provided check box in the left side for each employee name for delete operation. for all checkboxes, i gave Integer[] attribute name which is declared in Custom Actionclass.deleteaction is working fine. But when i click Find button the action is not getting submitted. Then i changed Integer[] to String[] both functions are working fine. What will be the problem? is it something like, attributes should only be String type.
The cause of your problem is that the Struts2 checkbox sets a boolean property on the action class:
Struts 2 Form Tags: Checkbox
When you defined the checkboxes as an Integers, the framework couldn't covert the boolean to an Integer. However it was able to convert the boolean to Strings. If you check the results in your action class, you should see the String[] populated with "true" and "false".
In general Struts2 is pretty good at converting submitted form data to whatever object type you want. Check out the docs on type conversion for more info.

Resources