Adding new Attribute to PaintTarget

Hi…

I am pretty new to It Mill.

I try to add maxlength attribute to an InputText.
I read this post http://forum.itmill.com/posts/list/319.page but it seems only applicable for version4.X. I am using the latest stable version 5.2.14
The maxlength attribute is not there yet.
What I did I create a new Class called StringInputText and extends com.itmill.toolkit.ui.TextField.

this is the code snapshot:


public class StringInputText extends TextField{
	private int maxLength;
	
	@Override
	public void paintContent(PaintTarget target) throws PaintException {
		super.paintContent(target);
		if (maxLength>0){
			target.addAttribute("maxlength", getMaxLength());
		}
	}
}

Unfortunately, that code is not working. Any idea what I am missing here.

Btw, for some reason, I can’t register to this forum. When I click on the “I agree to these terms” button, always stay in the same page.

Thanks in advance

Hi!

It Mill Toolkit is a server side framework, but we also need quite a lot of code for clients too. What you have done in your code is correct, but only the half of the job.

paint() method (or usually paintTarget() as one definitely wants to extend AbstractComponent) is used by “Terminal” to draw the component in UI. Although it might look like it, id doesn’t build HTML there, but a IT Mill Toolkit specific presentation of the current UI state. This is later processed by a small engine in browser (built with GWT) that renders the component to UI.

So what you still need is to make some modifications to or extend the client side component. Client side component live in com.itmill.toolkit.terminal.gwt.client.ui and have “I” prefix in their name.

Here are some links to get started with component customization:

Architecture overview:
http://toolkit.itmill.com/demo/doc/manual/ch02.html

Creating a custom component:
http://toolkit.itmill.com/demo/doc/manual/ch08.html

Ticket about this issue in trac (apparently we’d be happy to receive a patch):
http://dev.itmill.com/ticket/932

cheers,
matti

I registered a user just last week and it seemed to work. Just make sure that there isn’t any error in the registration form. The error message is shown in red color
below
the form and the captcha, so it is easy to miss it.

Please send a screenshot (here or to marko dot gronroos atmark itmill dot com) if the problem persists.

Hi again!

I decided to implement that ticket #932 so it will be available on tomorrows nightly if you need it quickly.

cheers,
matti

Which browser you are using? Are cookies enabled?

Hi…

Thanks for the reply.
Matti, thanks for implementing the maxlength. I will try that with the nightly build jar. I am going to try to extend the client side component like you suggested.

Regarding registration, I use Firefox 2 and cookies enabled. The problem that I face is in “Registration agreement terms” page(haven’t been to registration form yet). When I click on “I agree to this term” button, it will stay in the same page. Perhaps, my firewall block it. I will try to register from other machine.

Thanks.

Regards

PL

Hi…

Thanks for patch. I download the nightly build, 5.3.0_trunk_20081229.
I am able to see the maxlength. I try that with TextField without specifiy the number of row through setRows method.
It does work with firefox,chrome, and opera but it’s not working with IE. I try to set the number of rows, it works fine.
The work around that i can use is set the TextField’s row number to 1, then set the maxlength.
I guess It might have problem when rendering the input text in IE but I could be wrong.

I apologies for asking a stupid question, For IE, how does IT Mill render the page? I did try to viewsource but not all the code in there but I can see the html code through firefox. Am I missing something here?

Thanks.
Regards,

PL

Thanks.

Hi PL!

The IE issue you pointed out is now fixed to trunk. Brand new test build containing this fix can be downloaded here:
http://itmill.com/download/testing/trunk/itmill-toolkit-5.3.0_trunk_200812310844.jar

IE by default shows just the original html document downloaded from server. As IT Mill Toolkit relies heavily on Ajax requests and dynamic modification of the html document most of the content is not in “view source”. Use a tool like
http://en.wikipedia.org/wiki/IE_Developer_Toolbar
in IE inspect dynamically created DOM. Firebug is the equivalent tool for FF.

If you want to increase your knowledge of Toolkit’s rendering system, refer to manuals architecture overview and later check out the code in com.itmill.toolkit.terminal.gwt.client package.

cheers,
matti