• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Updating properties using wildcard

 
Greenhorn
Posts: 5
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

can any one tell me weather its possible to use wildcard to take values from drop down list and replace the value in properties file Using Jsp,Servlets

example

name=Welcome {1}

this {1} should get replaced with value from dropdown list
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

venkata naveenTeja wrote:can any one tell me weather its possible to use wildcard to take values from drop down list and replace the value in properties file Using Jsp,Servlets

example

name=Welcome {1}

this {1} should get replaced with value from dropdown list


It certainly can be done, but I think you need to specify your requirements a lot more clearly.

Suppose your properties file has a thousand lines: Is {1} specific to a particular line, or do you want to replace every instance of {1} with whatever you choose? The latter would suggest an 'identifier', so you'd better be sure you get it right.

Secondly: Do you actually want to replace the value in the properties file, or just its representation in memory? Again, the latter sounds more likely; otherwise you will lose all your {n} identifiers after replacement.

BTW: this type of encoding is called a 'placeholder', not a 'wildcard'.

Winston
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Class java.text.MessageFormat is meant to do exactly this. See its API documentation.
 
venkata Tekkem
Greenhorn
Posts: 5
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Winston Gutkowski - 1) Requirement is to overwrite the string {1} in the properties file itself not its instance in memory
2) where ever it is found as{1} its should get replaced with the string from drop down list ,My properties files contains 50 variables with {1} as sub string

 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

venkata naveenTeja wrote:1) Requirement is to overwrite the string {1} in the properties file itself not its instance in memory


Seems odd, since that means it can only be once done, which may make testing a bit awkward.

2) where ever it is found as{1} its should get replaced with the string from drop down list
My properties files contains 50 variables with {1} as sub string


Fine. That was more for your information than mine, so you know exactly what you're dealing with.

For the basic translation, you should definitely follow Jesper's advice, which is why it has so many 'thumbs up' points (including one from me).

Winston
 
venkata Tekkem
Greenhorn
Posts: 5
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Thank You both of you i finished my task using MessageFormat class
 
I guess I've been abducted by space aliens. So unprofessional. They tried to probe me with this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic