Before to open a bug to the Qt project, I'd like to ask you if I'm doing something wrong or the Qml Calendar is really going crazy.
It follows the code which can be used to test it:
import QtQuick 2.5
import QtQuick.Window 2.0
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.1
Window {
visible: true
width: 1024
height: 768
ColumnLayout {
anchors.fill: parent
anchors.margins: 8
Calendar {
id: calendar
Layout.fillWidth: true
Layout.fillHeight: true
weekNumbersVisible: true
selectedDate: new Date("2015/01/01")
frameVisible: true
focus: true
onVisibleMonthChanged: visibleMonthChangedRef.currDate = visibleYear+"/"+visibleMonth
onVisibleYearChanged: visibleYearChangedRef.currDate = visibleYear+"/"+visibleMonth
}
Label {
id: visibleMonthChangedRef
Layout.fillWidth: true
property string currDate: ""
text: "onVisibleMonthChanged -> " + currDate
Component.onCompleted: font.pointSize = font.pointSize*2
}
Label {
id: visibleYearChangedRef
Layout.fillWidth: true
property string currDate: ""
text: "onVisibleYearChanged -> " + currDate
Component.onCompleted: font.pointSize = font.pointSize*2
}
}
}
Easy going, start the application and you'll see a calendar as well as a couple of labels that report information about the visibleMonth and the visibleYear as provided by the Calendar component.
Those labels are filled accordingly to the onVisibleYearChanged and onVisibleMonthChanged of the Calendar.
The selected date is 2015/01/01.
Well, go back of a month towards the 2014.
The onVisibleYearChanged looks to be right while accessing the visibleMonth and visibleYear properties of the Calendar, while the onVisibleMonthChanged looks to me as living in a far future.
Now, try to move on of a month towards the 2015.
Again, while the onVisibleYearChanged is still behaving the right way, the onVisibleMonthChanged is accessing a Calendar component that is sitting in the past.
You can go back and forth over the new year and a function that is reacting to the signal onVisibleMonthChanged will never behave properly for it looks to me as invoked once all the internal properties have not been properly set yet.
That said, am I doing something wrong and thus the problem is within my code (of course, the one above is a small example from a more complex project) or I've really found a bug in the 'Calendar` component and I should proceed opening a ticket to the Qt project?
Even though it looks a bit strange to me asking to modify a component, being notified that it's updated, thus find that my changes have been only partially set (a kind of work in progress notification), that's it.
It seems that the error was in my expectations. :-)
Once the month moves on or back over the year (that is, from December to January and vice versa), the Calendar component correctly updates the property visibleMonth and the property visibleYear.
Anyway, the are no guarantees that the corresponding signals (onVisibleMonthChanged and onVisibleYearChanged) are emitted once the internal representation has been updated as a whole.
Actually, the former is emitted when the changes to the second property are still pending, thus querying the visibleYear property in a listener ends with the wrong year (or at least, a one not updated yet).
As an example of solution, the user of the component can work around this odd behavior by attaching a listener to both the signals, even though I strongly suspect the out there a better solution is waiting for me.
I'll manage to find an alternative approach.
Thank you for all of your responses.
Related
I think I am missing something.
In CakePHP 4.2 the new option allowMultipleNulls was added. The default value is FALSE. Is there a way to set it to TRUE for the whole project?
With this option I finally can save NULL values in unique fields without any effort.
Currently I have edited the line #39 in cakephp/cakephp/src/ORM/Rule/IsUnique.php and set it to TRUE but this is the death penalty as with the next CakePHP update this gets overwritten.
Currently CakePHP doesn't offer a simple way to set the default value to TRUE. I opened a new issue regarding this and now they are discussing about some principal questions and how to implement it in the most complicated way.
My point of view is that each underlying database engine accepts NULL in a unique index but CakePHP is baking here something completely strange and different.
In CakePHP 4.x it was removed and in CakePHP 4.2 it was re-introduced again but with the default FALSE.
However, as it may take ages until they implement a very simple method to set the default value to TRUE I am using the below few lines of code. The point is that the next CakePHP update overrides my modification in their source code and this breaks then my project.
Therefore I check each time in app_local.php the current default value of allowMultipleNulls and when it isn't TRUE then the project dies with a notification. A responsible developer isn't running an update while the business hours and tests after the update the site, so this solution is working for me very reliable without bothering the users. I can live with the very small delay which needs the execution of the code.
$voidIsUnique = new \Cake\ORM\Rule\IsUnique( [], [] );
$isUnique = new ReflectionClass(\Cake\ORM\Rule\IsUnique::class);
$property = $isUnique->getProperty("_options");
$property->setAccessible(TRUE);
if ( !$property->getValue($voidIsUnique) ["allowMultipleNulls"] ) {
die('<span style="background-color: black; color: yellow; font-size: 36px;">' .
'IsUnique::_options ["allowMultipleNulls"] is FALSE. Fix the source code!</span>');
}
$property->setAccessible(FALSE);
Once CakePHP team implemented something I will update it here.
I inherited a legacy website written in old zul and have to add new datebox component for birthday datepicker.
Have added a constraint to accept dates before a given date but that triggers an error alertbox from start as the date presented/selected by default on the datepicker is today.
I wouldn't want to use a workaround but to all due respect it seems like this is something over the top feature I'm looking for in zk's reality:
The main showcase for zul does include a birthday datebox, but pretty lame as it doesn't contain any constrain on age.
There is zk fiddler to show how the before constrain works, but that just proves my point that it doesn't select the first proper date for default date at least, if there is no clean way of setting it.
There is forum post that proposes a workaround to set the default year, so Zk is most probably incapable of doing this without a workaround.
There is an open ZK Jira issue from 2017 that addresses somewhat this issue, with a proposed solution pretty much the same as the workaround mentioned in the above point - so the hope is kinda lost, have to go on the workaround route.
I did try that workaround (after the forum post, as that has default year), but the workaround doesn't work for me. It does execute the
this.setValue(initialDate);
And I see that the value is set into the datebox's _pop/_value and _pop/_end nodes but no difference is visible on the datepicker box, still today is preselected altough it is greyed out - so no effect.
Still, when I try it in a fiddle with version 6.5.8.1, the oldest engine that exists, it does work, but not locally with v5.0.11.
In the buglist for this version there is no mention of datebox. Tried to look into to some bugs that might be interfering but turns out it was just another episode of me wasting time with this.
Tried in the 5.0.11 sandbox and it doesnt work with that version. The structure of how I use it is imitated in the linked fiddler. Hints on a workaround that works on this version?
ZK 5.0.11 is a bit on the older side currently, so it might not accept exactly the same overrides as later versions. If I understand the issue correctly, it boils down to either
1 - setting a value before Datebox is rendered to have a "initial date" opened in calendar.
I'd say that's the easy way out, since you can use either composing or databinding to set the value of the datebox during page rendering. Here's a small sample using databinding and zscripts, but the same logic should apply from composer with setValue(). You mentioned that this doesn't work for you locally with 5.0.11 though. Can you share the code that you are using for this? Sample code here in fiddle I can run it on local 5.0.11, and it set the date before popup is opened.
or
2 - setting an initial date (which doesn't affect the selected value) but would be the target for the opened calendar.
This is not a default ZK 5 behavior for datebox. If you want that effect, you would need to customize it using an override script. Simplest way in can think of in ZK 5 is to use the open event of the datebox popup here's an example of what it would look like (package in a script tag in a single page for the example, would use a global js file for real deployement) example here
I have a table that when I click on a row, in a side div I display the details. I have created an event on the row (tr) that is fired every time that row is clicked. The problem I have is that the event is being fired multiple times. It is acting as if a new view is being created everytime the event is fired, but a new view is not being created. Here is the code:
GroupView = class App.GroupView extends Backbone.View
template: App.Utils.getTemplate 'group'
selectedId: 0
events:
'click tr': 'selectGroup'
selectGroup: (e) ->
thisEl = $(e.currentTarget)
$(thisEl).closest('tr').siblings().removeClass 'selected'
$(thisEl).closest('tr').addClass 'selected'
#selectedId = $(thisEl).data().id
#getGroupDetails #selectedId
render: ->
$(#$el).html #template
groups: #collection.models
if #selectedId is 0
firstRowEl = $(#$el).find('tr:first')
$(firstRowEl).addClass 'selected'
#selectedId = $(firstRowEl).data().id
#getGroupDetails #selectedId
getGroupDetails: (id, platform) ->
$('<img/>',
src: 'img/ajax_loader_2.gif'
class: 'ajax-loader'
).appendTo '.group-details'
renderGroupDetails id
groupDetails = new GroupDetailsView
el: '.group-details'
model: groupDetailsModel
renderGroupDetails = (id)->
groupDetails.el = '.group-details'
groupDetails.stopListening groupDetailsModel
groupDetails.listenTo groupDetailsModel, 'change', ->
groupDetails.model =
groupDetails: groupDetailsModel.toJSON()
groupDetails.render()
groupDetailsModel.fetch
data:
id: id
processData: true
The issue is that when I use the groupDetails.stopListening groupDetailsModel, the multiple event firing issue is resolved but then NONE of the events in the groupDetails view is being fired.
Any help is appreciated.
Cheers,
Kianosh
So, giving you a specific answer is difficult: the code you've pasted is a bit hard to follow, and seems like it might be missing bits (eg. what's a groupDetailsModel? Does it have any logic that affects it's view?). That's ok though, because I think what you need here is more debugging help than a specific answer.
If I understand you correctly, your problem is that groupDetails.render() is being invoked extra times, and you're not sure why or what is invoking it: is that correct? If so, your trusty debugger can answer this in a matter of seconds.
NOTE: Everything I'm about to say applies to Chrome (with the built-in developer tools up) or Firefox (with the Firebug extension up) for sure. It probably applies to other browsers with their tools too, I just can't say for sure since I don't use them.
Approach #1: Debugger
With your debugger up, add a debugger; line as the first thing inside your GroupDetails.prototype.render method. This will make your browser pause on that line whenever it hits it. While its paused you can check the "call stack" on the right-hand side, and that will show you exactly what bit of your code just called that render. You can also use the debugger to inspect the values of the different variables in your environment to try and understand why your code is calling render.
Approach #2: Console.trace
If you're not a fan of using the debugger, there's another tool that's also perfect for answering this sort of question. Simply add console.trace() as the first line in your render method, then run your code as normal. This time your browser will log (to the "console") a stack trace generated from that point in the code. This stack trace is similar to the call stack that you can see when you use debugger, and thus it will tell you exactly what code invoked the render each time.
Hope that helps.
I've came across this issue today and I think I might need some help. We are using 1.6.1 version of Dojo, but this is cross version issue.
Steps to reproduce the following issue are pretty simple:
click the dojo doc link for Filtering Select dijit.form.FilteringSelect
On the documentation page, click the first FilteringSelect sample
In the Codeglass window sample, click the filteringselect and add "x" to "California", thus bringing it to invalid state
While focused, delete the "x" letter.
and here comes the problem. Technically the value is correct, but the dijit is still like in error state (unless it loses focus).
I'd like to get the dijit react and render correctly straightaway I delete the character causing the invalid state without losing focus.
Any ideas for the workaround?
Thank you.
ok. for eveyryone else interested the solution was 'quite' simple, just use the dijit.form.FilteringSelect._refreshState() .The underscore prefix is might not be someone's cup of tea but that was the only way to get it in correct state.
in our case it was a bit tricky as we are using the dojox.data.QueryReadStore wrapped in our own object and I needed the proper trigger which I've found in connecting to onComplete event of the inherited fetch() method.
I am trying to figure out how to make a hyperlink in a Livecycle Form which points to a URL which will change on different days that the form is rendered. For example on one day I might want the hyperlink to point to:
mywebsite/mypage?option=XXX
and on another day I want it to point to:
mywebsite/mypage?option=YYY
The XXX and YYY can be passed into the form's data pretty easily as XML, but I just don't know how to make it so that the hyperlink is changed to correspond to this.
Any suggestions?
This can be accomplished with JavaScript in LiveCycle Designer. The following script, placed on the Form's docReady event will let you dynamically change the URL of a text object.
form1::docReady - (JavaScript, client)
// If this code is running on the server, you don't want it to run any code
// that might force a relayout, or you could get stuck in an infinite loop
if (xfa.host.name != "XFAPresentationAgent") {
// You would load the URL that you want into this variable, based on
// whatever XML data is being passed into your form
var sURL = "www.stackoverflow.com"; // mywebsite/mypage?option=xxx
// URLs are encoded in XHTML. In order to change the URL, you need
// to create the right XHTML string and push it into the Text object's
// <value> node. This is a super simple XHTML shell for this purpose.
// You could add all sorts of markup to make your hyperlink look pretty
var sRichText = "<body><p>Foo</p></body>";
// Assuming you have a text object called "Text1" on the form, this
// call will push the rich text into the node. Note that this call
// will force a re-layout of the form
this.resolveNode("Text1").value.exData.loadXML(sRichText, false, true);
}
There are a couple of caveats: URLs in Acrobat are only supported in Acrobat 9.0 and later. So if someone using an older version of Acrobat opens your form, the URLs won't work.
Also, as you can see from the "if (xfa.host.name !=...)" line, this code won't run properly if the form is being generated on the server, because forcing a re-layout of a form during docReady can cause problems on certain older versions of the LiveCycle server. If you do need to run this script on the server, you should probably pick a different event then form::docReady.
I a number of complaints from users in WorkSpace that clicking links opened them in the same tab so they lost their WorkSpace form, and there's no option to change that in Designer 11. I think the solution I came up with for that would work for you too.
I made buttons with no border and no background, and in their click event have this line (in Javascript, run at client)
app.launchURL("http:/stackoverflow.com/", true);
It would be easy to add some logic to choose the right URL based on the day and it doesn't cause any form re-rendering.
In some spots where the hyperlink is in line with other text, I leave the text of the link blue and underlined but with no hyperlink, and just place the button (no background, no border, no caption) over it. Does require positioned and not flowed subforms for that to work, so depending on your layout it could get a little clunky.
Wow, just realized I am super late to the party. Well, for anyone using ES4 facing a similar problem . . .
Ended up using a 3rd party component to manipulate the PDF's hyperlinks...wish there was a better solution as this one costs about $1000.