0

Bandbox validation issue.

asked 2008-11-17 03:05:04 +0800

SergeTk gravatar image SergeTk
193 3

How does one validate bandbox , since validation fired on focus off if I'm not mistaken.

This presents following issue for me.

I have a bandbox with list dropdown/popup select from which should set value of bandbox ,
but when I do actual select the validation gets fired before my value is actually set for bandbox , hence I allways get
error.

How to I make sure that validation is only fired after I set bandbox value???

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2008-11-17 03:43:31 +0800

windperson gravatar image windperson
415 1

Hi SergeTK,

maybe you should implement your validation logic in onSelect event handler ?

for example:

	<bandbox id="bd">
		<bandpopup>
		<listbox width="200px">
                <attribute name="onSelect">
                 if(self.getSelectedIndex() != 1 ){
                     bd.value= self.selectedItem.label;
                 }; 
                 bd.closeDropdown();
                </attribute>
			<listhead>
				<listheader label="Name"/>
				<listheader label="Description"/>
			</listhead>
			<listitem>
				<listcell label="John"/>
				<listcell label="CEO"/>
			</listitem>
			<listitem>
				<listcell label="Joe"/>
				<listcell label="Engineer"/>
			</listitem>
			<listitem>
				<listcell label="Mary"/>
				<listcell label="Supervisor"/>
			</listitem>
		</listbox>
		</bandpopup>
	</bandbox>

link publish delete flag offensive edit

answered 2008-11-17 05:15:52 +0800

SergeTk gravatar image SergeTk
193 3

Thank you for the reply, but if I do that wouldn't that stop validating the typing into bandbox and only validate the selection??

As it stands right now input can be either typed in by user directly or selected from dropdown.

link publish delete flag offensive edit

answered 2008-11-17 11:14:12 +0800

windperson gravatar image windperson
415 1

Hi SergeTK,
you can set readonly="true" in bandbox to prevent user input value by typing:

<bandbox id="bd" readonly="true">
		<bandpopup>
		<listbox width="200px">
                <attribute name="onSelect">
                 if(self.getSelectedIndex() != 1 ){
                     bd.value= self.selectedItem.label;
                 }
                 bd.closeDropdown();
                </attribute>
			<listhead>
				<listheader label="Name"/>
				<listheader label="Description"/>
			</listhead>
			<listitem>
				<listcell label="John"/>
				<listcell label="CEO"/>
			</listitem>
			<listitem>
				<listcell label="Joe"/>
				<listcell label="Engineer"/>
			</listitem>
			<listitem>
				<listcell label="Mary"/>
				<listcell label="Supervisor"/>
			</listitem>
		</listbox>
		</bandpopup>
</bandbox>

link publish delete flag offensive edit

answered 2008-11-17 20:19:22 +0800

SergeTk gravatar image SergeTk
193 3

Hi Windperson, disabling of input is not an option for me as it also performs function of auto-complete which is a necessity for quick selection/search from large list of data.

link publish delete flag offensive edit

answered 2008-11-18 03:49:53 +0800

windperson gravatar image windperson
415 1

Hi SergeTk,
I'm sorry to tell you that this is a bug.
http://sourceforge.net/tracker/?func=detail&atid=785191&aid=2307954&group_id=152762
http://sourceforge.net/tracker/?func=detail&atid=785191&aid=2307993&group_id=152762
so the feasible way right now is to write event handler of onSelect event in the listbox inside the bandbox and onChanging event in bandbox to validate user input.

link publish delete flag offensive edit

answered 2008-11-18 08:14:59 +0800

windperson gravatar image windperson
415 1

Clarified, the first problem is that we should use

bd.setValue(self.selectedItem.label)
instead of
bd.value = self.selectedItem.label;

to avoid beanshell's bug (http://sourceforge.net/tracker/?func=detail&atid=785191&aid=2307954&group_id=152762)
And as to the regular expression, please refer to the POSIX standard:
http://en.wikipedia.org/wiki/Regular_expression#POSIX

so if we want to modify the demo code in in developer reference (http://www.potix.com/doc/devref/ch04s02s04.html) to let user only select the third entry "Mary", the code should be:

<bandbox id="bd" constraint="/^M.*/">
		<bandpopup>
		<listbox width="200px">
                <attribute name="onSelect">
                 bd.closeDropdown();    
                 bd.setValue(self.selectedItem.label);
                </attribute>
			<listhead>
				<listheader label="Name"/>
				<listheader label="Description"/>
			</listhead>
			<listitem>
				<listcell label="John"/>
				<listcell label="CEO"/>
			</listitem>
			<listitem>
				<listcell label="Joe"/>
				<listcell label="Engineer"/>
			</listitem>
			<listitem>
				<listcell label="Mary"/>
				<listcell label="Supervisor"/>
			</listitem>
		</listbox>
		</bandpopup>
</bandbox>

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2008-11-17 03:05:04 +0800

Seen: 348 times

Last updated: Nov 17 '08

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More