0

Textbox with huge value

asked 2011-07-13 06:41:41 +0800

meh gravatar image meh
57 1

Hello,

I have a textbox where the contents can be quite huge. Does anyone know of some way to avoid storing the entire contents in a String? I need to be able to scroll the entire content, so I don't see maxlength as an option.

Any ideas would be welcome.
Thanks

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2011-07-13 09:57:05 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

hi Meh,
do you mean you want the textbox show a very long string as multi line?
try the simple sample below.

<window title="My First Window" border="normal" width="400px">
	<textbox id="tb" multiline="true" rows="6" width="350px" />
	<button label="set content">
		<attribute name="onClick">
			StringBuilder sb = new StringBuilder("");
			for (int i = 0;i != 200;i ++) {
				sb.append("a very long content, ");
			}
			tb.setValue(sb.toString());
		</attribute>
	</button>
</window>

link publish delete flag offensive edit

answered 2011-07-14 04:13:31 +0800

meh gravatar image meh
57 1

Hi Benbai,

Thanks for the tip, but I think I will have to put a limit on the size of an uploaded text file that a user is allowed to edit. From both the application's and the user's point-of-view, it is probably not practical to try to edit large text files in a textbox...

Best Regards,
meh

link publish delete flag offensive edit

answered 2011-07-14 04:23:49 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

updated 2011-07-14 04:28:39 +0800

Hi Meh,

maybe you can check the length of a string directly by length() API before set it into the value of textbox,
or check the size of a file directly by length() API before process it.

link publish delete flag offensive edit

answered 2011-07-14 08:13:24 +0800

meh gravatar image meh
57 1

Yes, I think that's what I will do. I was hoping that maybe there was some sort of paging mechanism for textbox so that not all of the text is in memory at the same time (like for listboxes).

Thanks,
meh

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: 2011-07-13 06:41:41 +0800

Seen: 188 times

Last updated: Jul 14 '11

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