Preet Dhillon

Greenhorn
+ Follow
since May 20, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Preet Dhillon

I have two different languages for my Struts 2 application. I have properties files for each language extension, default.properties and default_fr.properties.

I am using the following code to switch the language and all works fine.



Then, I went to add tiles. I have tiles.xml and tiles_fr.xml in my WEB-INF. Language switching for tiles work independent of the "request_locale". It only works when I change language in the browser.

I have tried making various changes to web.xml and struts.xml but can't seem to figure out how to get the tiles to change language with the hyperlink.

Any advice would be appreciated.

Thanks in advance.
4 years ago
Not sure if this is the best approach but it works so I am going to mark it as resolved...


Added the child list to the model:

and called the options within the while loop of the parent list:
4 years ago
I am stumbled again on trying to implement a nested iterator using this sample.

http://struts.apache.org/release/2.1.x/docs/crud-demo-i.html

In the doList() method of the action, I need to add another iterator that should be populated by id of the exiting list (employee.employeeid)





I have already created a table in the database with this relationship. I have also got the service, model and dao to extract the data from the database by a given employeeid. But I am completely lost as to how and where to pass the employeeid parameter to populate the sub-list to generate the nested iterator.

Any ideas how to connect the nested list. This nested list is supposed to populate different form fields. For example, radio buttons, check boxes etc...

4 years ago

Perfect! Thank you. This is exactly what I was looking for...

Wondering if there is a way to improve the duplicated dropdown code? For example, is it possible to just update the listValue based on the locale rather than write the complete select twice.



4 years ago
Thank you. If I understand you correctly I don't need the MAP...

I need to a step further with this and add department names in French as well. The drop-down needs to be populated in user’s locale choice.

What would be the best way to do that add another column to the table “name_fr” or add new row for each locale and have column named “locale” hold the values (en and fr)?

How and where would I access user’s locale and pass to the SQL query (i.e., jsp, action or DAO).

Thanks again!
4 years ago
Hello,

I am in the process to convert this sample app from Apache site http://struts.apache.org/release/2.1.x/docs/crud-demo-i.html to use a database back end.

I am able to successfully populate a drop-down from the database but I am not sure if my code is correct. Here is the code original code:



Please take a look to see if it all makes sense - I need to have both list and Map return types. Here is my updated code to incoroporate database:



4 years ago


resolved - apparently, "redirect-action" is "redirectAction" in struts 2.3.X.X
4 years ago


I am following this sample from Struts 2 Design and Programming: A Tutorial by Budi Kurniawan.

I get an error "description The requested resource (/app10a/Employee_list.action) is not available." When I take out the following line, List action works


but the create action gives me a similar error.

"The requested resource (/app10a/Employee_create.action) is not available."

I can't seem to figure out how to correct this - any ideas?

Thank you in advance.
4 years ago
Okay- Thank you.

So the two examples I've found so far on the Struts site are following:

First one has the i18n but no dropdowns and checkboxes ets... http://struts.apache.org/development/2.x/docs/processing-forms.html

Second one had the all the elements and uses array to populate but no i18n - http://struts.apache.org/development/2.x/docs/struts-2-form-tags.html

Second form is closer to what I need but how would I include i18n to this?

My apologies - I am very new to Struts and have little experience with Java/jsp/servlets.

I've gone through all tutoraial on the this site and have good understing of individual elements but little confused on combining it all.

4 years ago
I have a requirement to build an online questionnnaire in two languages using Sturts 2 framework. The questions are a combination of various form fields (eg. text, dropdown, radio and checkboxes) - roughly 15-20 questions.

I am trying to figure out a way to generate the questions for this questionnaire. What is the best approach - storing the questions in the database or in the resources file?

Thank you in advance.
4 years ago

In the code above - I am trying to replace the Arrays.asList parameters to a text file





What method of file I/O stream should I be using for this purpose. Aslo, can it return a List<String> stooges from this method?

Thank you!
5 years ago
In the code sample provided by Sunder Ganapathy for the dropdown, is there a posibility to pass locale from jsp to the DAO?

My database table is setup for different locales and I am currently working with something like this: ("select * FROM tablename WHERE tablename.locale='en_CA'")

I need the locale to change when user switches language. I am thinking of keeping locale in a session variable but not sure if it would be a good practice to specify session variable in the WHERE clause. Are there other better options?

Thank you in advance.
5 years ago
JSP
It's straight from the book (page 34-35). I guess you are supposed to modify them before you can try and test them
It's very frustrating but I can't run these files. I've tried many options.

1. h:\Java\SCJP\Ex2> java other\Child
2. h:\Java\SCJP\Ex2\other> java Child
3. I've tried to change the Classpath to h:\Java\SCJP\Ex2\other

I get the same error - Exception in thread "main" java.lang.NoClassDefFoundError
It's working now - I've found out what I was doing wrong.



set CLASSPATH=h:\Java\SCJP\Ex2
set PATH=%PATH%;c:\Program Files\Java\jdk1.6.0_06\bin
cd h:\java\SCJP\Ex2


I was trying to run Javac from c:>

javac certification\Parent.java
javac other\Chile.java


Once I changed to H: drive, both files compiled.

Thanks for your help!