Stephane Eybert

Ranch Hand
+ Follow
since Mar 15, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
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 Stephane Eybert

I solved the issue by using the TypeResolver of TypeTools from Jonathan Halterman at https://github.com/jhalterman/typetools

Here is the code chunk I used:


Thanks to you Jonathan !
11 years ago
Hi Paul,

Thanks for the comment. Here is the class source code. The line "41" is at line 12 in this post.

11 years ago
Hello,

I have the following classes...

A generic DAO class:


A domain DAO class extending the generic DAO class:


A database server specific domain DAO class extending the domain DAO class:


The compile is perfectly happy with the above.

But running the test demo class:


gives the following exception:

Exception in thread "main" java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType
at com.thalasoft.learnintouch.core.dao.hibernate.GenericHibernateDao.<init>(GenericHibernateDao.java:41)
at com.thalasoft.learnintouch.core.dao.hibernate.UserHibernateDao.<init>(UserHibernateDao.java:26)
at com.thalasoft.learnintouch.core.dao.h2.hibernate.UserCustomHibernateDao.<init>(UserCustomHibernateDao.java:17)
at com.thalasoft.learnintouch.core.exception.TestDemo.main(TestDemo.java:8)



Any clue ?
11 years ago
Hi Rob,

I know, I feel the same, that's why I'm right now still looking at it, trying to dig around..

Stephane
I don't know what happened, but the issue does not show up anymore.
Hello Rob,

I just see your last post, sorry for not having seen before, strange because I made sure to refresh the page before my last post.

Stephane

11 years ago
I tried a new take, this time not using the enum construct.






11 years ago
I think the preferences of one module should sit in an array so as to be traversable and displayed in a list.
11 years ago
I tried to come up with a design but I'm mildly satisfied with my production here.

So here is what I did.

There is a common Preference class:



Which is used by other Preference classes, each for a module of the application:



The application module can then read the preference value with:



I don't know why, but I don't like it.
11 years ago
Ok Rob, I shall try that road then, cheers.
11 years ago
I could skip the enum then.

Any design advice ?
11 years ago
Thanks Rob. I used the ResourceBundle class in the past.

My issue lies more with the constants and how to load them:



I guess I could have in each module, an enum along the lines of:

public enum Preference {

DOCUMENT_NB_PER_ROW("My label1", "My help1", PREFERENCE_TYPE_RANGE, array(1, 10, 3)),
DOCUMENT_DISPLAY_ALL("My label2", "My help2", PREFERENCE_TYPE_BOOLEAN),
DOCUMENT_HIDE_SELECTOR("My label3", "My help3", PREFERENCE_TYPE_BOOLEAN);

private String label;
private String help;
private int type;
private Array possibleValues;

Preference(String label, String help, int type) {
this.label = label;
this.help = help;
this.type = type;
}

Preference(String label, String help, int type, Array possibleValues) {
this.label = label;
this.help = help;
this.type = type;
this.possibleValues = possibleValues;
}

public String getLabel() {
return this.label;
}

public String getHelp() {
return this.help;
}

public String getType() {
return this.type;
}

}

As I would have such an array in each module of the application, would it be possible to have each enum class extend on a common one ?

Something like an enum extending anoterh base enum:

http://freddy33.blogspot.com/2007/05/why-java-enum-cannot-extends.html
11 years ago
Hello,

I have a legacy php application which has multiple modules, each one having a set of preferences supporting language localized strings.

For example, the "document" module has the following preferences:



The language text strings are stored in text files sitting in the file system next to the script like:

DocumentUtils.php
.DocumentUtils.en.php
.DocumentUtils.se.php

Here is the content of one such language text file:

[ 0]Document to download:
[ 1]Download the document
[ 2]Ref:
[ 3]Download
[ 4]Display all the documents:
[ 5]By default, when no category has yet been selected by a visitor of the website, only the documents of the first category are displayed.\n\nBut it is possible to display all the documents instead of only the ones of the first category.
[ 32]Number of documents per row:
[ 33]The lists of documents can display several documents per row.\n\nThe number of documents per row can be modified.\n\nThe number of images per row can be modified.
[ 6]Hide the selector:
[ 7]By default, a category selector is displayed on top of the list of documents.\n\nBut this selector can be hidden to prevent the selection of another category.

The preferences values are stored in a database table:

mysql> desc preference;
+---------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| version | int(10) unsigned | NO | | NULL | |
| name | varchar(50) | NO | UNI | NULL | |
| value | text | YES | | NULL | |
| type | int(10) unsigned | NO | | NULL | |
+---------+------------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)

mysql> select * from preference limit 10;
+----+---------+----------------------------+-------------+------+
| id | version | name | value | type |
+----+---------+----------------------------+-------------+------+
| 1 | 0 | FLASH_INTRO_HIDDEN | 1 | 1 |
| 2 | 0 | FLASH_INTRO_DISPLAY_ONCE | 1 | 1 |
| 3 | 0 | FLASH_INTRO_DISPLAY_PERIOD | 0 | 7 |
| 4 | 0 | FLASH_INTRO_POPUP | 1 | 1 |
| 5 | 0 | FLASH_INTRO_PAGE_BG_COLOR | | 8 |
| 6 | 0 | FLASH_INTRO_SKIP_LINK | | 2 |
| 7 | 0 | FLASH_INTRO_POPUP_WIDTH | 900 | 2 |
| 8 | 0 | FLASH_INTRO_POPUP_HEIGHT | 900 | 2 |
| 9 | 0 | CLOCK_DATE_NUMERIC_FORMAT | %d-%m-%Y | 6 |
| 10 | 0 | CLOCK_DATE_FORMAT | %A %e %B %Y | 6 |
+----+---------+----------------------------+-------------+------+
10 rows in set (0.00 sec)

And so now I wonder how to go to code a preference manager that would be compatible with the existing data.

I already have the data access layer in Java including domain class, mutators and finder..

But I still need the coupling with the hard coded names in the code and the languages text strings.

Any tip would be welcome.

Thanks !

Stephane

11 years ago
I worked around the problem by decoding the variable in the JSP page.

12 years ago
Hello,

I have a controller building up a url.

The & is not encoded and that is how this url should be.

However, when this url is passed to a model attribute, it ends up being encoded in the JSP view.

Here is the source code of the controller:



The original value was not url encoded as can be seen in the log:

2012-03-20 13:33:52,290 DEBUG [AnnotateController] =============>>> Controller requestUrl: 1&2



But the JSP page shows it encoded:

http://localhost:8080/annotate-web/1&2

I would like the framework NOT encoded my url, as I want to encode some parts of it only.

Stephane
12 years ago