How can I autogenerate keytyped events. java - post

I have a setup that sends keypresses from a third party application, to my java application.
The java app receives the keycode, and from that I generate a KEY_PRESSED event, like so:
keyEvent = new KeyEvent(clientCanvas,KeyEvent.KEY_PRESSED,System.currentTimeMillis(),0,keyCode0,keyChar0);
eventQueue.postEvent(keyEvent);
This works for non unicode keys such as enter, esc, delete...
But it does not cause characters to be typed.
I believe I have to make a KEY_TYPED event to type a character.
How would I generate the key typed event correctly, taking into account key combinations? For example, shift+4 should generate the a $ symbol on my keyboard.

Related

BigDecimalField validation bug

BigDecimalField has a nice feature: it allows only digits, "+" and "-" signs, and a decimal separator defined by the current locale ("." or ","). It works fine until someone tries to enter a combination that is not a number or cannot be directly converted to the java BigDecimal type (e.g "123...45.6+++7-89--").
For sach combinations, the validation passes without any warning, and the background business object gets a null value.
Field is in the dialog and every time before opening the dialog there is a call to Binder.readBean() method (in order to set the appropriate data for editing), on "save" button in dialog I call Binder.writeBean(). Problem is that the next time I open the dialog, the problematic BigDecimalField still contains an invalid number entered,
actually Binder.readBean() stops working for that field.
There is a similar bug with IntegerField which I noticed: IntegerField validation bug.
How can I validate BigDecimalField and avoid this bug? How do i get the BigDecimalField to work again and not keep showing invalid data? Is there a elegant way to catch the NumberFormatException that probably occurs somewhere inside the vaadin api, and proces it i.e. warn the user that he has to enter a valid decimal number. Is there a way to do it via Binder?
I am using Vaadin 23.3.0
Checking format error is not yet by default on. You need to enable it by setting enforceFieldValidation=true in feature flags in src/main/resources/vaadin-featureflags.properties file.
com.vaadin.experimental.enforceFieldValidation=true
See more at: https://github.com/vaadin/platform/issues/3066

How do you print different templates in netsuite?

I am trying to find the correct template and id to use for a hotprint of an advanced pdf template of an Item Fulfillment.
The hot print url is (with the id bolded) https://system.na3.netsuite.com/app/accounting/print/hotprint.nl?regular=T&sethotprinter=T&id=7600&label=Packing%20Slip&printtype=packingslip&trantype=itemship&orgtrantype=TrnfrOrd&auxtrans=7605
For some reason only certain id=# seems to affect the outcome and the ids I have got to work for two different templates don't match the Custom Transaction Forms ID or the Advanced pdf script id. (example most ids=template 1, while 168,4954, and seemingly random other ids=template 2) I am very confused on how netsuite resolves the hot print url as it normally doesn't include the template= part though I have seen others use it for invoice print urls.
The parameters at the end of the url (the stuff after the ?) are used by Netsuite to control settings used by the webpage which prints the PDFs for you.
In this case, &id=##### refers to the internal id of the document you are printing. You can see this by going to the document, right clicking, selecting inspect, and typing nlapiGetRecordId() into the console. When you click Print, you should see that same number after &id=#####.
&template=### refers to the template you are printing. If you go to Customization -> Forms -> Advanced PDF/HTML Templates, you'll notice a Script ID field in the table. If you substitute the correct Script ID in for the number in &template=###, you'll notice you generate the same PDF. This Script ID acts the same as the number that was previously there.
The reason you're seeing unusual results when you change those numbers is because you're mismatching a record with a template not built for it. So it won't print exactly right, but will sometimes execute anyways.
Anyways, this sort of parameter scheme is a similar scheme to how Suitelets and Restlets work, so in the future, you might experience this sort of thing again.
EDIT: For those reading this in the future, please read the comments.
To customize a packing slip and return form:
If you are printing packing slips and need some customization, you can use a custom invoice form when printing packing slips. For example, you can customize an invoice form to hide the fulfilled item tax rate and amount, and the order total. Then, when you print the packing slip using the custom form through mass print, choose the the packing slip shows the customized information.

Key pressing events in Dart

I have read the docs for the KeyEvent class (link here), and also several SOF questions, but I still can't make Dart listen to my key press. I'm using Polymer-dart 0.16, and could do it with core-a11-keys, but it doesn't incorporate the PLUS and MINUS keys, which I need.
From a custom element <myElement> that I defined, I want to be able to listen to different keys being pressed (anywhere in the element). This element has of course its correspondings html and dart files. Should I listen the key being pressed from the html or the dart? The doc seems to specify that both the listening and the handling are done in the dart with this example:
// Initialize a stream for the KeyEvents:
var stream = KeyEvent.keyPressEvent.forTarget(document.body);
// Start listening to the stream of KeyEvents.
stream.listen((keyEvent) =>
window.console.log('KeyPress event detected ${keyEvent.charCode}'));
...
// Add a new KeyEvent of someone pressing the 'A' key to the stream so
// listeners can know a KeyEvent happened.
stream.add(new KeyEvent('keypress', keyCode: 65, charCode: 97));
I guess that last line is simulating an user pressing a key. But if I don't add it, no key press is listened.
In short terms:
Could someone please give a simple example of how to listen and handling the key press event?
EDIT
A simple way of imagine what I'm trying to do, is to think about Google Inbox. Let's say you have several mails on your inbox, and you want to move between them. In this app you can do it with LEFT and RIGHT arrows (along with many other shortcuts for different actions).
I'm trying to do something similar with Dart. Let's say that I have a custom element <my-element> where all the mails are shown. I want this element to be able to listen to some events, like UP and DOWN keys being pressed. Using core-a11-keys, I was able to do it, putting
<core-a11y-keys target="{{ body }}" keys="up"
on-keys-pressed="{{ selectPreviousItem }}"></core-a11y-keys>
inside the myElement.html (inside the tag <polymer-element name='my-element'>), where selectPreviousItem is my handler for the event, which is a method in myElement.dart. The thing is that core-a11-keys doesn't have all the possible keys on a keyboard (which I need). Therefore, I'm trying to do exactly the same thing but without core-a11-keys, this is: listening and handling the event of the user clicking UP (or others keys) when the focus is somewhere in <myElement> (the focus for example could be in <myNestedElement> inside <myElement>).

wc3270 script file inserting user input

I would like to know how to insert scripted user inputs into the wc3270 emulated environment. An example is the inserting of the "tso" command and then automating login process for user.
Below is a script I wrote that doesn't seem to load the string when needed.
connect(192.168.10.102:23)
ascii()
String tso
Are there ways to input user strings ?
Maybe need read the manual user for do that.
In your example String tso send tso to actual position cursor, if the cursor are placed in bad site or not in input site, then that not work.
You can use MoveCursor for correct the cursor position.

special character coming when i am using & and p

I dont know what exactly i have to type in title for this ,i tried my best
anyway coming to topic
I am making one acc checker for that purpose ,i am sending user and pass from my bsskinedit1 and bsskinedit2
here is my code
s:='http:\\site.com..premlogin='+bsskinedit.text+'&password='+bsskinedit2.text
but it giving some error ,then i used showmessage whats wrong with it then i came with strange result
see below
observer after 4 & and p combining together and appearing as a some new symbol :(
can any one tell me why its coming like this ?
Your code (where you build the URL) is most likely correct (I guess the above has some typos?!), but when you display the URL in a label for instance, the & character is treated as indicator for an accelerator key.
By Windows design, accelerator keys
enable the user to access a menu
command from the keyboard by pressing
Alt along the appropriate letter,
indicated in your code by the
preceding ampersand (&). The character
after the and sign (&) appears
underlined in the menu.
If you want to display the & character itself, you have to set your string variable to &&.
By placing two ampesands together - you state that the character following the first one is not used as the accelerator - rather you actually want to get it (only one) displayed.
Just use your debugger if you want to see the real value that your string variables have, don't output them to a message box or the like... It may have side effects, as you can see.
Regarding the URL you build: I can't possibly know how it has to be correctly, but at least you should use the right slashes!
s := 'http://site.com...'
(All quotes from delphi.about.com)
In addition to what Mef said, you can use OutputDebugString to add your string to the event log in its raw form, so you don't need to modify it before displaying it. Delphi should capture those strings automatically if you're running from the debugger. If you aren't running it from Delphi you can use DebugView instead, which captures the messages from any running applications.

Resources