1

Concat @bind

asked 2014-02-19 12:08:00 +0800

wigberto gravatar image wigberto
52 4

updated 2014-03-04 17:10:30 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

How do i can "concat" a string with @bind? Example

src="'/img/32/number'.concat(@bind(each.slotNumber)).concat('blue32.png')"
Thank you
delete flag offensive retag edit

Comments

is your question resolved?

chillworld ( 2014-03-04 18:59:19 +0800 )edit

Yes, thank you.

wigberto ( 2014-03-28 09:19:45 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2014-02-19 14:22:38 +0800

bbolek gravatar image bbolek
98 1 5

You can write your own concat method in your class.. Then use it like this:

value="@bind(vm.concat(vm.order.firstName,' ',vm.order.lastName))" 


public String concat(String... a)
{
    String returnString="";
    for(int i=0;i<a.length;i++)
    {
        returnString=returnString+a[i];
    }
    return returnString;
}
link publish delete flag offensive edit

Comments

(For info and improving your skills, it's not critic cause your code is good) You can yes but if I wrote your code I should do this : first @load in stead of @bind. Second use an for each, yes that works also on arrays, thirth use Stringbuilder, what is a lot more efficient than returnString=returnString+a[i] fourth if you want to implement varargs what is good, write a method for 1 - 2 (and 3) Strings and for the x strings that you will use the most. This is also more effecient then the varargs.

chillworld ( 2014-02-19 15:02:11 +0800 )edit

Thanks for info:)

bbolek ( 2014-02-19 18:09:38 +0800 )edit
0

answered 2014-02-19 12:21:39 +0800

chillworld gravatar image chillworld flag of Belgium
5337 4 9
https://github.com/chillw...

updated 2014-02-28 20:09:15 +0800

You will have to use el expressions.

Now I don't think you need to @save the element so do just an @load.
@bind() = @load() @save()

<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<label value="@load(c:cat3('/img/32/number',each.slotNumber,'blue32.png'))"/>

Greetz chill.

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2014-02-19 12:08:00 +0800

Seen: 118 times

Last updated: Mar 04 '14

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