• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsf-html with jstl-core

 
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Himalay Majumdar
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic