Apache wicket: how to add a zero padding to DateTimeField? - apache

I've got a page with DateTimeField.
When i'm filling only date field (leaving hours and minutes fields empty) and have a validation error (page get's reloaded, feedback panel is shown), time fields got filled in with 0:00. But the thing is, that I want to have 00:00.
As I inspected, minutes field got ZeroPaddingIntegerConverter(2), so I just simply add it to hours field. But the thing is I cannot add anything to hours field as it is private.
So is there a way to add a ZeroPaddingIntegerConverter(2) to a hours field in DateTimeField of Apache Wicket ?

I use the DateTextField provided in the org.apache.wicket.extensions.markup.html.form package
DateTextField myDateTextField = DateTextField("endTime", "HH:mm");
You can define a date pattern that will be used for formatting the date. The time will be displayed with two digits for the hour and a leading zero if necessary.

Related

Using datepicker in DotNetNuke-7 module

I'm a DNN beginner. I am currently building a module in which I can display statistics. My DotNetNuke Version is 7.0. The statistic is from Chartjs. For this statistic I would like to implement filters. These filters should be datepickers. As UI element I have now included a textbox with TextMode='Date'. But currently I have problems to set the default value of this field. The default value should be 01.01. of the current year.
I have already tried to set the value via C# server side. Unfortunately without success. I also tried to set the value on the client side via JavaScript. Unfortunately also without success.
These are some lines I tried in JavaScript:
document.getElementById(<%= this.DatumVon.AccessKey %>).value = "01.01.2019";
document.getElementById(<%= this.DatumVon.AccessKey %>).innerText = "01.01.2019";
document.getElementById("DatumVon").value = "01.01.2019";
These are some lines I tried in C# in the method "Page_Load" (server side):
this.DatumVon.Text = "01.01.2019";
I expected the value of the TextBox to be 01.01.2019. However, it currently only contains dd.mmm.yyyy. How can I change this?
Thank you.
There is something wrong with your localization. Please refer to the jQuery UI datepicker documentation (the "Localization" section), this should give you the answer.
wow... I solved it. I made it. Sometimes the solution is right in front of you and you don't see it. Michael Tobisch was absolutely right. When setting the value, the format is very important. I have always used the German format. A DNN TextBox with TextMode="Date" can't handle that. DNN converts this TextBox into an HTML input field. But this input field can only be clear with the format "yyyy-mm-dd". Depending on the geographical position of the client (at least that's what I think) the text displayed in the input field will be formatted. But the value of the input field always has the same format ("yyyy-mm-dd"). So very important here: the displayed text and the actual value have different formats.
Many thanks again to Michael Tobisch for the mental inspiration and the patience with me.
What is also important is that the access to the actual ID of a DNN element works as follows: this.Element.ClientID and not as I assumed before this.Element.AccessKey. This was also buggy.

VSTO accessing date of message as entered in the header

in VSTO I want to access the date of a sent message as it appears in the recipient clients header. Sent Items return an empty transport header (for obvious reasons) however I can't find a date to match the date that a non exchange recipient system would get from the message header.
I've tried:
CreationTime();
PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x30070040").ToString(); //MAPI creation time
.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x30080040").ToString(); //MAPI last modification time
.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0E060040").ToString(); //MAPI Date Message Delivered
But none of them match the actual Date: that appears in the header on the recipient end. Taking into account timezones, etc. the Date field is a couple of seconds off.
Any ideas on how to access the date of a sent item as it appears to the clients? I would have expected date of delivery or date of creation to match.
Try PR_CLIENT_SUBMIT_TIME (DASL name http://schemas.microsoft.com/mapi/proptag/0x00390040). Also keep in mind that OOM always rounds the date/time properties to the nearest second.

Selecting a datetime range in YII input form

Here is the problem.
I have to create a submission form on my Yii-based website. The form requires to enter a datetime range.For that I am using "jui datetimepicker" third-party Yii extension.
http://www.yiiframework.com/extension/datetimepicker/
I use two date fields with this extension pertaining to start and end time respectively. So, what I want to achieve is be able to restrict the start datetime only to time in the future (neither past dates nor time should be selected) and the end time itself should be restricted to the maximum of three hours following the start time.
EXAMPLE: a user wants to schedule an event. They choose a date and time, which are of course in the future. Let's say they choose March 15, 13 O'clock as the start time in the start time field. Once they are done and move to the next field ("end time"), the respective datetimepicker restricts the range of time from March 15, 13:00 to March 15, 16:00.
Hence the second datetimepicker should be dynamically updated depending on the input of the first one.
It's possible o specify date range in the datetimepicker starting from the current date, but there is nothing like that for the time selection, so a user still can select time which has already passed.
It's not that I want to solve this problem with this extention, if anybody has any suggestions about YII solutions allowing to specify a datetime range in the most clean and effective way - it would be much appreciated.
You should use the edaterangepicker extension instead.
Given the API for the jquery timepicker addon. you should add the following to your widget call (along side 'model','attribute', etc)
'options'=>array(
'minDateTime'=>'<start dateTime here>',
'onSelect'=>'<JS function to run>'
)
The function you run on the "onSelect" event should dynamically set the minDateTime for the second dateTime input field, for ex:
function (selectedDateTime){
<EndDatePickerElement>.datetimepicker('option', 'minDateTime', <start dateTime here using selectedDateTime> );
}
There are more examples on the link provided earlier if you need to make it even more precise (like say if you wanted the starting date to be pushed back by the amount of time the user was on the page rather than it being set when the page was loaded. etc...)

Sharethis api top shared urls

I'm working on building a block on my site that contains the top 5 most shared urls on my domain via the sharethis api, I've been testing it and have gotten some unexpected results...
when I check the domain statistics api, I get the expected results:
request:
http://rest.sharethis.com/analytics/V2/getDomainStats.php?domain={my-domain}&pub_key={my-publisher-key}&access_key={my-secret-key}
response:
{"status":"SUCCESS","from_date":"20120620","to_date":"20120627","data":
{"domain_summary":[{"clicks":1092,"shares":134,"traffic":1393,"date":"06\/20","channel_stats":
[{"shares":86,"clicks":404,"traffic":412,"channel":"facebook"},
{"shares":25,"clicks":617,"traffic":898,"channel":"email"},
{"shares":12,"clicks":0,"traffic":0,"channel":"fblike"},
{"shares":7,"clicks":42,"traffic":31,"channel":"twitter"},
{"shares":3,"clicks":0,"traffic":0,"channel":"plusone"},
{"shares":1,"clicks":0,"traffic":0,"channel":"pinterest"},
{"shares":0,"clicks":17,"traffic":19,"channel":"blogger"},
{"shares":0,"clicks":12,"traffic":33,"channel":"google_bmarks"}]}.....
I've truncated those results obviously since they go back for a week...
when I try to find out what urls are the most active from my domain:
request:
http://rest.sharethis.com/analytics/V2/getTopUrlStats.php?domain={my-domain}&from_date=2012-06-27&to_date=2012-01-01&pub_key={my-publisher-key}&access_key={my-secret-key}
response:
{"status":"SUCCESS","from_date":"20120627","to_date":"20120101","last_batch_date":"20120626","data":{"top_urls_summary":[]},"today":""}
Obviously this is not what I'm looking for, I have the clicks and on the sharethis site I can go to my metrics and view the info I'm looking for with no problem, but the api is not answering with any data. I have tried changing the date range or omitting it completely (which for some reason returns an empty data set) to no avail. Has anyone else run into a similar problem?
Ok Sharethis support finally got back to me about the problem:
According to sharethis api :
To Date End date for data. Note: date must be in yyyy-mm-dd format. Default is 7 days ago.
From Date Start date for data. Note: date must be in yyyy-mm-dd format. Default is 'today'.
These are backwards, that's 1 reason why my call wasn't working, "To date" should be the more recent date when defining the date range... the "defaults" don't work so you must enter both values, and when you enter todays date as the "To Date" it may return "collection failed", so best to start with yesterday

SharePoint Workflow Error: "Unable to transform the input lookup data into the requested type" BUT only on New Item Creation

FYI to start, I am aware of how to properly set up an update to a lookup, and am 99% positive I've done this correctly.
I know this because When I set the workflow to automatically start when an Item is Changed, then it works perfectly. But when I simply change this setting so it will automatically start on New Item Creation, it Cancels the workflow and I get a "Coercion Failed: Unable to transform the input lookup data into the requested type." If both options are checked then it fails on creation, but simply clicking edit on the item properties, and the "Save" makes it work.
The workflow is on a Document Library and works as follows;
User selects the Work Task LookUp from a dropdown in the edit properties form after uploading, and then Saves the item (adding it to the document library). The workflow is suppose to then look at the Work Task LookUp selected, and pull the Account and Effective Date-Type lookUp ID's that Work Task item has, and sets the Document's identical fields to the same value.
Here is the code for the workflow if it helps;
If Current Item: Parent Task is not empty
If Current Item: Sub Task is not empty
Log Both are empty to workflow history list
Then Set Account to Work Tasks:Account
The Log Set Account to workflow history list
Then Set Effective Date and Type to WorkTasks: Effective Date and Type
The Log Set EffDateType to the workflow history list
This is all done in one step. I also added additional steps to test if the account and effective date type fields have been set properly, and if not to set them again. But everytime I run the workflow on change and it works, it always correctly sets these fields based upon the first Step (posted above) and the additional check logs to the history that they are not needed.
As an example, The lookUp for Integer for Tasks:Account is set to work as follows;
Date Source: Work Tasks (a list)
Field from Source: Account (a lookup)
Return Field as: Lookup ID (as Integer)
Find the List Item
Field: Title (from the Work Tasks list)
Value: Current Item: Parent Task (Which is a look up of the "Title"
Field from Work Tasks List, and is set to return the Value as a LookUp Value (As Text))
The Effective Date and Type setting is pretty much identical.
So anyone have any insight? I've tried running it as an impersonated Step, setting a workflow pause (for 1 minute), changing the lookup types incase I messed it up to start with, but ultimately the above workflow DOES work, but only when I set it to "Automatically start on the Change (edit) of an Item", NOT "Automatically start on New Item Creation" like I need to to do.
Oh yes, fyi, I am using SPServices CascadingDropDown on the Work Task and Sub Task fields of the doc Library form, but I honestly do not believe this has anything to do with my issue.
UPDATE:
I've talked with another developer, and he believes it is due to the issue that the workflow is occuring too quickly, before the item creates an ID for itself, which it needs to conduct the lookUps. He had me add another "Pause Workflow" to the very top of my workflow code (above the If conditions) and set it for 1 minute.
It then worked properly.
Downside is we want this to labeling to occur as close to item creation as possible. Because a view of the library relies on grouping based upon Account and Effective Date and Type. To add to this downer, Microsoft's Pause Workflow only allows for 1 minute or more, and then the timer used for this is often off, resulting in a pause longer than that. So far, every test is currently showing 2 minutes minimum on the pause.
A possible alternative solution for instantaniously populate the fileds is to use Javascript and SPServices to do the lookUp to the Task list to pull the account and effective date - type fields and then populate, but my Javascript is not very strong and I would need help doing this. If anyone has any suggestions, I would appreciate them.
(Answered in a question edit. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )
The OP wrote:
I don't know if it is the ID for the item after further testing. I changed the start of the workflow to wait until a field in the item changes. I set it to wait until the ID field is not 0 (since you cannot set to null), and it still does not work.
6/14/2012 4:13 PM Comment System Account Waiting on ID ​
6/14/2012 4:13 PM Comment System Account Waiting complete on ID ​
6/14/2012 4:13 PM Error System Account Coercion Failed: Unable to transform the input lookup data into the requested type.
I have tried other fields as well, like document ID value is not empty, and it will wait, log it finishing the wait, and then fail.
UPDATE This issue has something to do with the Parent Task field. I have solved the issue without having to wait for a period of time by setting the change from above to wait until the Parent Task field is not empty. It then completes the workflow fine.
Anyone know why there is a delay though? I've solved it, but still don't fully understand what takes it so long.
The main fault has been solved (hence the answer), and the remaining point about the reasons for the delay would probably be a discussion point or not specific enough for SO. Any further clarification can be edited in here.