This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSF and the fly likes jsf-html with jstl-core Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "jsf-html with jstl-core" Watch "jsf-html with jstl-core" New topic
Author

jsf-html with jstl-core

Himalay Majumdar
Ranch Hand

Joined: Sep 28, 2008
Posts: 324
Hi All,

I am trying to format the zipcode by adding a hyphen when its length is more then 5. i.e, 111111111 becomes 11111-1111.
I tried the following code (without synthesizing the bean getters). It gives me the following error while submitting (not while accessing).

"Illegal Syntax for Set Operation" for <h:inputText value="#{Source.zipCode.subSequence(0,5)} - #{Source.zipCode.substring(5)}"> </h:inputText>

I think its not a good idea to combine jstl and jsf together, but is there a work around for this. Thank you.



SCJP 1.6, SCWCD 5.0, SCBCD 5.0 [loading..]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

You have coded an rvalue expression as the value for an input text control. You can't do that. Inputs must be lvalues (as in on the [b]left[b] side of an assignment statement).

I think you're also expecting JSTL to work on the client like it was JavaScript, and that doesn't work either, but the main thing is that you have an invalid input tag definition.


Customer surveys are for companies who didn't pay proper attention to begin with.
Himalay Majumdar
Ranch Hand

Joined: Sep 28, 2008
Posts: 324
Thank you for the rvalue-lvalue correction Tim.
May I know what makes you think I expect JSTL to work on the client like JavaScript, please let me know what would have been your approach for something like this.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

If you expect people to be able to type in a ZIP code and have the '-' inserted as it's being typed, that would require client-side logic.

For server-side logic, actually the easiest thing to do is present a property that does all the string concatenation (and de-concatenation) in the backing bean.
Himalay Majumdar
Ranch Hand

Joined: Sep 28, 2008
Posts: 324
I can do this server-side by introducing a property in the backing bean as you said.
In Client side, do you mean we need to code client logic only when '-' must be inserted as ZIP is being typed, I guess that would require some event calls which would need new bean properties and hence some server-side work as well. Please clarify. Thanks.

-Himalay
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsf-html with jstl-core