On ItemChanged event of datawindow, I have to prompt a message on wrong input.
The issue is: When I use messagebox(), It prompt message correctly but field is not being blank and by pressing TAB, the control is being shifted to next field. (means its accepting the wrong value by pressing TAB key again)
Here is simple code for above scenario:
if lb_error = true then
messagebox('Info','Only Digits Are Allowed ~nAll Digits Cannot Be 0')
this.object.payer_phone[1] =''
end if
Then I tried Modify property, Its working fine but Is there any possibility to change Its title and icon?? I am using following code and , Kindly help me.
if lb_error = true then
this.Modify("payer_phone.ValidationMsg='Only Digits Are Allowed ~nAll Digits Cannot Be 0'")
this.object.payer_phone[1] =''
return 1
end if
I am using PowerBuilder 12.0.
From the PowerBuilder help:
Return Values
Set the return code to affect the outcome of the event:
0 (Default) Accept the data value
1 Reject the data value and do not allow focus to change
2 Reject the data value but allow the focus to change
So in your case you need to RETURN 1 from the itemchanged event.
Since you are handling this error in itemchanged you need to 'bypass' the itemerror event. You do this by placing a RETURN 1 there.
By triggering the error in the itemchanged event you can create a custom error messagebox or use the system default and control the title, icon, buttons, etc.
Assuming payer_phone is the field being edited, I believe you need SetText() instead of setting the underlying value in the data set.
To understand this difference, you need to know that for data entry, there is a control "floating above" the DataWindow, moving from field to field with focus. When the entered data is accepted, the value in the floating control is flushed to the data set of the DW. GetText() and SetText() deal with that floating control. Your code is changing the DW data set. After the first error, the next time you press Tab, no change in the control has been detected, so the functionality that fires when data changes doesn't occur, and your error code never kicks off.
Good luck.
You can modify the icon and title by using the same function MessageBox with a different signature :
MessageBox ( title, text {, icon {, button {, default } } } )
HTH,
Ali
You can modify the icon and title by using the same function MessageBox with a different signature : MessageBox ( title, text , icon , button , default )
HTH, Ali
Related
Sommeone please tell on how to get get cursor position in lightning input rich text in lightning web component.
I am using the following code but getting undefined:
let element = this.template.querySelector("lightning-input-rich-text");
console.log(element.selectionStart, element.selectionEnd);
I wouldn't call it a complete solution.
Use "window.getSelection()" to get the selection indexes, however you might want to ensure the rich text was in focus when selection occurred.
the specified method will return a Selection object, anchorOffset & extentOffset properties will contain the start and end indexes.
I have a select box in application where user have to select any one option and the moment when user select the option its corrosponding message should be printed along with the selected option for e.g in my code when user select APPLE as an option the corrosponding value of the apple which is "A healthy fruit,better for breakfast" should be printed ,
I tried with this value option but seems not working for me , any clue ?
here is my demo code
https://codesandbox.io/s/material-demo-xj3df
The value message is hidden !
Here is the codesandox https://codesandbox.io/s/material-demo-jvse7
There are couple things I need to change
Change value from object to string
Added print message
Selectfield will find the label from the value of MenuItem.
I'm building account system using sencha touch (architect) and now I have an issue where the code executed but the this.getMainView().pop(); NOT and the view states on current one !
my views:
Login scrn--> cstmrs list--> cstmr details--> rceipt--> checks
When I get to receipt view (without checks) the code executed and auto returned to customer's details view.
But soon I click to add a check to the receipt (only displaying the form without any code) the check view injected to mainview after that I click back button to return to receipt window, but now when I click save button the receipt is saved and the data arrives server side ok, but the big problem the this.getMainView().pop(); doesn't work or doesn't executed !!
Is there any wrong with my code? it works without displaying the 'checks' form !
Nothing in firebug/chrome debugger
I use this code to show forms:
var mainView=this.getMainView();
mainView.push({xtype: "frmChcks",title:'new check'});
And this code for getting back:
this.getMainView().pop();
Thank you in advice
Ahhhh it was because I used a hidden field called 'id', don't use 'id' for you components :-)
I am using Telerik Combobox with EnableLoadONLoad = True i.e. Every time end user type a letter, server side event kicks in to pull records for that word. For example, In the dropdown box, if I type America then the system will search for A then AM then AME and so on... and brings results that matches those letters. So, in the case above, the system will ick server side event 7 times. Now the problem is search functionality takes a while (anywhere from 5 - 10 seconds to pull records.. beyond my control :( ) What I want is when end user type something , I want to wait for a second to see if user is still typing. After a second, I want the system to go for search. Hoping that within a second, end user will type whatever they need to. Now I can force the user to type minimum 5 letters and so on but end user can search with a single letter or multiple letters. They don't want to be restricted with no. of letters due to business requirements.
You can just specify an 'ItemRequestTimeout' in milliseconds of 1000 which will tell the combobox to wait 1 second before firing to the server.
The itemRequestTimeout on their comboboxes is 300 by default which is 3 tenths of a second. doing what Brian Suggested would work, but I have found that the default is usually enough time before it causes the postback.
Also if you incorporate MarkFirstMatch="true" for the ComboBoxes it will automatically go to the item that matches the text if it exists.
http://demos.telerik.com/aspnet-ajax/combobox/examples/populatingwithdata/autocompletesql/defaultcs.aspx
This should give you some other options as well.
But as far as forcing the user to enter 5 letters before the postback occurs, You would probably need to do onkeyup and onkeydown javascript events to check if they have entered 5 characters and then you could cause the postback.
Or you could use the OnClientkeyPressing property of the Telerik comboboxes to do the check.
function OnClientKeyPressing(comboBox, args)
{
if (comboBox.get_text().length > 4) {
//Do postback here
}
}
Something like that would do what you want I believe.
In our project we use ZK for webpages. There is a combobox which has lists. When selected, it fetches data from a java object through onSelect, i have given the logic.
when i select one there are 4 listboxes on that page to be filled with data according to the selection. when i select first time, no problem occurs.
But on second time i get an error pop-up like "Not Unique in the id space of Window" and showing the list box item id which have to be filled on select.
Can any one help out there?
Note: Though it shows this error i get the listboxes filled correctly according to the combo box selection. Still i cant stop this error occurring..
Your issue is a conflict of ids in ZK's id space.
A bit of background..
ZK generates ids for components at runtime, if you open up the DOM in the browser you'll see each component has some machine readable id.
However, you can also give components an id. This id does not go to the DOM but lets you reference the component in your application.
These two shouldn't be confused. The conflict you're experiencing is with the latter type of id; you are assigning a component an id in your Java code or in your ZUL file which, at runtime, is not unique.
The case you describe where it only happens the second time you click is a tell tale sign here. The content you are adding on the event has an id defined in it and you are not removing this content when you are done.
Consider the following example:
#Wire
private Window myWindow;
#Listen(Events.ON_CLICK + " = #myButton")
public void onMyButtonClicked() {
Label myLabel = new Label("sean is cool");
myLabel.setId("myLabel");
myLabel.setParent(myWindow);
}
This will work the first time you click myButton, but will throw your error on the second click. That is because the second event tries to add myLabel to myWindow but there is already a myLabel there.
There are lots of ways to resolve this depending on what you are trying to do.
Have a look through the ZK documentation on ID Spaces for more.
I also faced the same error.
My scenario is the same, only the widgets being used are different.
Hence putting my workaround here.
I have put the following piece of code in the doBeforeCompose() method of the composer:
Component widgetWithId = page.getFellowIfAny("widgetWithId");
if (widgetWithId != null) {
widgetWithId.detach();
}
Here widgetWithId is the component/widget, which is tried to be regenerated by the code, with the same Id and ZK is throwing error for it.