You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by unka_hahrry <un...@hotmail.com> on 2008/04/02 16:51:05 UTC

Writing to .properties files and make changes happen?

I'm using a BufferedWriter to change my .properties files dynamically, the
.properties files are updated well but the changes don't appear in my
<wicket:message> tag. Is there a possiblity to reload a .properties file?
-- 
View this message in context: http://www.nabble.com/Writing-to-.properties-files-and-make-changes-happen--tp16447118p16447118.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Writing to .properties files and make changes happen?

Posted by Azzeddine Daddah <wa...@gmail.com>.
Why don't you try to use the Apache Commons Configuration?
Take a look http://commons.apache.org/configuration

Azzeddine

On Fri, Apr 4, 2008 at 8:35 AM, unka_hahrry <un...@hotmail.com> wrote:

>
> I call this method from inside a WebPage:
>
> public static void setNewText(String path, String textId, String
> neuerText)
> throws IOException {
>
>                ... getting old text as StringBuffer "alt" ...
>
>                //create new String from content of .properties file
>                String neu = alt.replace(start, ende,
> neuTextTeil).toString();
>
>                          File output = new File(path);
>                          BufferedWriter out = new BufferedWriter(new
> FileWriter(output));
>
>                try {
>                        out.write(neu);
>                    }
>                    finally {
>                        out.close();
>                    }
>
>        }
> That's all. The .properties file will be changed correctly, but the new
> content will only take effect if I open the .properties file with an
> editor
> and save it, but the overwriting process won't be recognized.
>
>
> Johan Compagner wrote:
> >
> > thats very strange
> > writing  a file in an editor or save it through java that shouldn't
> matter
> > But are you constantly writing properties file from inside the webapp?
> >
> > johan
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Writing-to-.properties-files-and-make-changes-happen--tp16447118p16484561.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Azzeddine Daddah
www.hbiloo.com

Re: Writing to .properties files and make changes happen?

Posted by unka_hahrry <un...@hotmail.com>.
Damn... Yes, it was the false path... Obviously the .properties file must be
changed in the context of classes, not in the source...

Thank you very much!!!

Johan Compagner wrote:
> 
> What  is the path you write it in? Where sits the property file?
> 
> On 4/4/08, unka_hahrry <un...@hotmail.com> wrote:
>>
>> I call this method from inside a WebPage:
>>
>> public static void setNewText(String path, String textId, String
>> neuerText)
>> throws IOException {
>> 		
>> 		... getting old text as StringBuffer "alt" ...
>> 		
>> 		//create new String from content of .properties file
>> 		String neu = alt.replace(start, ende, neuTextTeil).toString();
>>
>>                           File output = new File(path);
>>                           BufferedWriter out = new BufferedWriter(new
>> FileWriter(output));
>> 		
>> 		try {
>> 			out.write(neu);
>> 		    }
>> 		    finally {
>> 		    	out.close();
>> 		    }
>>
>> 	}
>> That's all. The .properties file will be changed correctly, but the new
>> content will only take effect if I open the .properties file with an
>> editor
>> and save it, but the overwriting process won't be recognized.
>>
>>
>> Johan Compagner wrote:
>> >
>> > thats very strange
>> > writing  a file in an editor or save it through java that shouldn't
>> matter
>> > But are you constantly writing properties file from inside the webapp?
>> >
>> > johan
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Writing-to-.properties-files-and-make-changes-happen--tp16447118p16484561.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Writing-to-.properties-files-and-make-changes-happen--tp16447118p16491007.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Writing to .properties files and make changes happen?

Posted by Johan Compagner <jc...@gmail.com>.
What  is the path you write it in? Where sits the property file?

On 4/4/08, unka_hahrry <un...@hotmail.com> wrote:
>
> I call this method from inside a WebPage:
>
> public static void setNewText(String path, String textId, String neuerText)
> throws IOException {
> 		
> 		... getting old text as StringBuffer "alt" ...
> 		
> 		//create new String from content of .properties file
> 		String neu = alt.replace(start, ende, neuTextTeil).toString();
>
>                           File output = new File(path);
>                           BufferedWriter out = new BufferedWriter(new
> FileWriter(output));
> 		
> 		try {
> 			out.write(neu);
> 		    }
> 		    finally {
> 		    	out.close();
> 		    }
>
> 	}
> That's all. The .properties file will be changed correctly, but the new
> content will only take effect if I open the .properties file with an editor
> and save it, but the overwriting process won't be recognized.
>
>
> Johan Compagner wrote:
> >
> > thats very strange
> > writing  a file in an editor or save it through java that shouldn't matter
> > But are you constantly writing properties file from inside the webapp?
> >
> > johan
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Writing-to-.properties-files-and-make-changes-happen--tp16447118p16484561.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Writing to .properties files and make changes happen?

Posted by unka_hahrry <un...@hotmail.com>.
I call this method from inside a WebPage:

public static void setNewText(String path, String textId, String neuerText)
throws IOException {
		
		... getting old text as StringBuffer "alt" ...
		
		//create new String from content of .properties file
		String neu = alt.replace(start, ende, neuTextTeil).toString();
                          
                          File output = new File(path);
                          BufferedWriter out = new BufferedWriter(new
FileWriter(output));
		
		try {
			out.write(neu);
		    }
		    finally {
		    	out.close();
		    }

	}
That's all. The .properties file will be changed correctly, but the new
content will only take effect if I open the .properties file with an editor
and save it, but the overwriting process won't be recognized.


Johan Compagner wrote:
> 
> thats very strange
> writing  a file in an editor or save it through java that shouldn't matter
> But are you constantly writing properties file from inside the webapp?
> 
> johan
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Writing-to-.properties-files-and-make-changes-happen--tp16447118p16484561.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Writing to .properties files and make changes happen?

Posted by unka_hahrry <un...@hotmail.com>.
I call this method from inside a WebPage:

public static void setNewText(String path, String textId, String neuerText)
throws IOException {
		
		... getting old text as StringBuffer "alt" ...
		
		//create new String from content of .properties file
		String neu = alt.replace(start, ende, neuTextTeil).toString();
                          
                          File output = new File(path);
                          BufferedWriter out = new BufferedWriter(new
FileWriter(output));
		
		try {
			out.write(neu);
		    }
		    finally {
		    	out.close();
		    }

	}
That's all. The .properties file will be changed correctly, but the new
content will only take effect if I open the .properties file with an editor
and save it, but the overwriting process won't be recognized.


Johan Compagner wrote:
> 
> thats very strange
> writing  a file in an editor or save it through java that shouldn't matter
> But are you constantly writing properties file from inside the webapp?
> 
> johan
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Writing-to-.properties-files-and-make-changes-happen--tp16447118p16484561.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Writing to .properties files and make changes happen?

Posted by Johan Compagner <jc...@gmail.com>.
thats very strange
writing  a file in an editor or save it through java that shouldn't matter
But are you constantly writing properties file from inside the webapp?

johan

On Thu, Apr 3, 2008 at 7:31 PM, unka_hahrry <un...@hotmail.com> wrote:

>
> Yes, but only if I edit the .properties file with an editor and save, then
> it
> will be recognized, if overwriting the .properties file with
> BufferedWriter
> it will not be recognized.
>
> Is there a better way to provide the future admin the possiblity of
> adaptable content, without putting all the text into the database?
>
>
> igor.vaynberg wrote:
> >
> > do they reload properly if wicket is running in development mode?
> >
> > -igor
> >
> >
> > On Wed, Apr 2, 2008 at 7:51 AM, unka_hahrry <un...@hotmail.com>
> > wrote:
> >>
> >>  I'm using a BufferedWriter to change my .properties files dynamically,
> >> the
> >>  .properties files are updated well but the changes don't appear in my
> >>  <wicket:message> tag. Is there a possiblity to reload a .properties
> >> file?
> >>  --
> >>  View this message in context:
> >>
> http://www.nabble.com/Writing-to-.properties-files-and-make-changes-happen--tp16447118p16447118.html
> >>  Sent from the Wicket - User mailing list archive at Nabble.com.
> >>
> >>
> >>  ---------------------------------------------------------------------
> >>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>  For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Writing-to-.properties-files-and-make-changes-happen--tp16447118p16466443.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Writing to .properties files and make changes happen?

Posted by unka_hahrry <un...@hotmail.com>.
Yes, but only if I edit the .properties file with an editor and save, then it
will be recognized, if overwriting the .properties file with BufferedWriter
it will not be recognized.
 
Is there a better way to provide the future admin the possiblity of
adaptable content, without putting all the text into the database?
 

igor.vaynberg wrote:
> 
> do they reload properly if wicket is running in development mode?
> 
> -igor
> 
> 
> On Wed, Apr 2, 2008 at 7:51 AM, unka_hahrry <un...@hotmail.com>
> wrote:
>>
>>  I'm using a BufferedWriter to change my .properties files dynamically,
>> the
>>  .properties files are updated well but the changes don't appear in my
>>  <wicket:message> tag. Is there a possiblity to reload a .properties
>> file?
>>  --
>>  View this message in context:
>> http://www.nabble.com/Writing-to-.properties-files-and-make-changes-happen--tp16447118p16447118.html
>>  Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>>  ---------------------------------------------------------------------
>>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>  For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Writing-to-.properties-files-and-make-changes-happen--tp16447118p16466443.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Writing to .properties files and make changes happen?

Posted by Johan Compagner <jc...@gmail.com>.
i think you have to do something with the Localizer
overwrite this method:

/**
     * Put the value into the cache and associate it with the cache key
     *
     * @param cacheKey
     * @param string
     */
    protected void putIntoCache(final String cacheKey, final String string)
    {

with an empty impl when in development

johan


On Wed, Apr 2, 2008 at 5:46 PM, Igor Vaynberg <ig...@gmail.com>
wrote:

> do they reload properly if wicket is running in development mode?
>
> -igor
>
>
> On Wed, Apr 2, 2008 at 7:51 AM, unka_hahrry <un...@hotmail.com>
> wrote:
> >
> >  I'm using a BufferedWriter to change my .properties files dynamically,
> the
> >  .properties files are updated well but the changes don't appear in my
> >  <wicket:message> tag. Is there a possiblity to reload a .properties
> file?
> >  --
> >  View this message in context:
> http://www.nabble.com/Writing-to-.properties-files-and-make-changes-happen--tp16447118p16447118.html
> >  Sent from the Wicket - User mailing list archive at Nabble.com.
> >
> >
> >  ---------------------------------------------------------------------
> >  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >  For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Writing to .properties files and make changes happen?

Posted by unka_hahrry <un...@hotmail.com>.
Yes, but only if I edit the .properties file with an editor and save, then it
will be recognized, if overwriting the .properties file with BufferedWriter
it will not be recognized.
 
Is there a better way to provide the future admin the possiblity of
adaptable content, without putting all the text into the database?
 

igor.vaynberg wrote:
> 
> do they reload properly if wicket is running in development mode?
> 
> -igor
> 
> 
> On Wed, Apr 2, 2008 at 7:51 AM, unka_hahrry <un...@hotmail.com>
> wrote:
>>
>>  I'm using a BufferedWriter to change my .properties files dynamically,
>> the
>>  .properties files are updated well but the changes don't appear in my
>>  <wicket:message> tag. Is there a possiblity to reload a .properties
>> file?
>>  --
>>  View this message in context:
>> http://www.nabble.com/Writing-to-.properties-files-and-make-changes-happen--tp16447118p16447118.html
>>  Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>>  ---------------------------------------------------------------------
>>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>  For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Writing-to-.properties-files-and-make-changes-happen--tp16447118p16466443.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Writing to .properties files and make changes happen?

Posted by Igor Vaynberg <ig...@gmail.com>.
do they reload properly if wicket is running in development mode?

-igor


On Wed, Apr 2, 2008 at 7:51 AM, unka_hahrry <un...@hotmail.com> wrote:
>
>  I'm using a BufferedWriter to change my .properties files dynamically, the
>  .properties files are updated well but the changes don't appear in my
>  <wicket:message> tag. Is there a possiblity to reload a .properties file?
>  --
>  View this message in context: http://www.nabble.com/Writing-to-.properties-files-and-make-changes-happen--tp16447118p16447118.html
>  Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org