CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Java

 Dynamily restrict a size of all label fields in one row

Print topic Send  topic

Author Message
Elmar

Posts: 17
Posted: 05/03/2006, 8:44 AM

Hi!

Another day, another task. IŽd like to restrict the size of all fields in one row. How do I loop over fields in one row? Of course I could always do it manually for each field by doing something like:

int length = 0;
length = e.getValue().length();
if(length > 40){length = 40;}
e.setValue( e.getValue().substring(0,length) ) ;

in the beforeShow event of the particular component. But as a lazy Developer IŽd prefer to do write this code once in the beforeShowRow Event of the form.

Ideally IŽd love to have something like e.getAllRowControlsThatContainNamePattern("_lang_") that returns a collection so I can just iterate. Or is there another way to do this... properly?

Thanks in advance,
Elmar

View profile  Send private message
LH_13

Posts: 30
Posted: 05/03/2006, 8:56 AM

You can modify common class com.codecharge.components.Control.setValue(...) and cut value in case of Label.
For implementing getAllRowControlsThatContainNamePattern(...) metod you can modify common class too.
But i think better use com.codecharge.components.Page for including this method. Because Page have all information about it's children in inside itself.
Event have this information too, but it incapsulate in Page.
_________________
Sorry my english!
View profile  Send private message
miko

Posts: 50
Posted: 05/03/2006, 10:41 PM

Hi!

I think that com.codecharge.components.Component class is the best place to implement method like getAllRowControlsThatContainNamePattern because all components inherite it.
The second point about wished behaviuor is the possibility to create your own action to do this work. YS actions are xslt-templates and can be added by your hand. You can see Components/Actions/Server/Database/SetPageSize.xml as example. It is not difficult to create new action as you wish.
_________________
Regards,
Michael
View profile  Send private message
Elmar

Posts: 17
Posted: 05/15/2006, 3:12 AM

Just to let you now... I extended the StringUtils class with two methods because it really is a string operation on certain fields. Of course it would be nice to have a wrapper function (like a collection of fields for one row) that I can call when the row ist build up so that I donŽt have to write a handler for every row field...
...
public static String cutString(String text, int size){
int length = 0;
length = text.length();
if(length > size){length = size;}
return text.substring(0,length);
}

public static String cutString(String text, int size, String append){
int length = 0;
length = text.length();
if(length > size){length = size;} else {append = "";}
return text.substring(0,length) + append;
}
...

Best regards,
Elmar
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.