[RFC][Icedtea-Web]: Ensure all ports entered are numeric values
Andrew Su
asu at redhat.com
Tue Apr 5 13:27:13 PDT 2011
ping.
I've updated file to apply cleanly to head.
Regards,
Andrew
----- Original Message -----
> ----- Original Message -----
> > On 03/21/2011 02:58 PM, Andrew Su wrote:
> > >> On 03/21/2011 01:51 PM, Andrew Su wrote:
> > >>
> > >>> v1 does not alert the user (silently ignore input). v2 alerts
> > >>> the
> > >>> user via popup.
> > >>>
> > >>
> > >> Only v2 will be applied, right?
> > >
> > > only one of the two, was more of asking for an opinion to whether
> > > we
> > > want to have silent handling of the input. or nag.
> > > I've fixed up v2 (now v3) assuming you wanted it to display
> > > something.
> > >
> >
> > Ah, ok. I thought v2 was an improved version of v1 (and I was
> > wondering
> > why you posted v1 at all). I dont really see a problem with dialogs.
>
> okay.
>
> >
> > >>
> > >>> 20110321_number_only_v1.patch
> > >>>
> > >>>
> > >>> @@ -254,4 +262,28 @@
> > >>> enablePanel(panel, false);
> > >>> }
> > >>> }
> > >>> +
> > >>> + /**
> > >>> + * Creates a PlainDocument that only take numbers if it will
> > >>> create
> > >>> a valid port number.
> > >>> + * @return PlainDocument which will ensure numeric values only
> > >>> and
> > >>> is a valid port number.
> > >>> + */
> > >>> + public static PlainDocument getNumberDocument(final Component
> > >>> c){
> > >>> + return new PlainDocument(){
> > >>> + public void insertString(int offs, String str, AttributeSet a)
> > >>> throws BadLocationException {
> > >>> + if (str != null) {
> > >>> + try {
> > >>> + Integer.valueOf(str);
> > >>> + int val = Integer.valueOf(this.getText(0, this.getLength()) +
> > >>> str);
> > >>> + if (val< 1 || val> 65535) { // Invalid port number if true
> > >>> + throw new NumberFormatException("Invalid port number");
> > >>> + }
> > >>> + super.insertString(offs, str, a);
> > >>> + } catch (Exception e) {
> > >>> + // Just don't insert.
> > >>> + }
> > >>> + }
> > >>> + return;
> > >>> + }
> > >>> + };
> > >>> + }
> > >>
> > >> What about remove()? How is deleting port numbers handled?
> > >
> > > What issues do you see with removing numbers? If you are only
> > > allowed to add numeric values..
> > > Removing them will still leave you with numeric values.
> > >
> >
> > I am wondering how a port value of "" will be dealt with.
>
> This only controls the input, that is handled by DocumentAdapter
> already.
>
> Regards,
> Andrew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20110405_number_only_v4.patch
Type: text/x-patch
Size: 6805 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20110405/2de8eaa4/20110405_number_only_v4.patch
More information about the distro-pkg-dev
mailing list