aspose file tools*
The moose likes Struts and the fly likes how to access java's Properties class in struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to access java Watch "how to access java New topic
Author

how to access java's Properties class in struts2

rajarao yerra
Greenhorn

Joined: Dec 21, 2009
Posts: 2
Hi All,
I have a properties file and through the Java's Properties class i am accessing the values in my property file. Now i have a requirement that i have to edit the property values.

EX: abc.properties is my properties file. in that i have entries like this
message1=hello mesage1
message2=hello mesage2
message3=hello mesage3
message4=hello mesage4
now i have to give a chance to user to edit those values(hello message1,hello message2,...). and i have to save the user give entry on that field.

Please help
Regards,
Rajarao
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

Hi rajarao, welcome to javaranch.

If you just want to know how to modify a properties file, see an example like this...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
rajarao yerra
Greenhorn

Joined: Dec 21, 2009
Posts: 2
Hi Ankit,

Thanks for your quick reply.
But this is not what i am looking.
java: Properties myNewProp = new Properties();

JSP: <s:iterator value="%{allProps.propertyNames()}" status="rowstatus">
<s:checkboxlist name="chk" list="%{top}" id="brand" value="%{top}" />
<s:textarea id="abc" cols="10" rows="5" value="%{allProps.getProperty(top)}" />
<br/>
</s:iterator>

Here is the Problem. i would like to store the User edited content. In <s:textarea> how i have to declare this(name attribute) .

OGNL expression.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

rajarao, I'm not very clear what you are trying to do with that iterator. You've not used var (or id) attribute which will represent the current iteration value. You are using the work top but I don't think that will represent the current iterated item. Also why are you using checkboxlist?? I'm sure you want to generate a single checkbox for one textfield (you are using textarea and again I feel you should use textfield instead still this is your choice). If I were you, what I would do is iterate over the properties, generate one checkbox for one textfield, and use the name of the key as the name of the textfield. Something like this

When this form will be submitted, you can have a List named chk which will contain the the keys of the selected properties. You can use the keys to get the corresponding values from the request. This is the solution that I can think of. You'll need access to request parameters so you'll need to use the ParameterAware interceptor. Also I would personally also use some javascript so textareas would be disabled by default and will be enabled only when the corresponding checkbox is checked. This will allow you to only submit the values whose checkbox is checked so that unnecessary information is sent in the request...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to access java's Properties class in struts2