Killing threads in Application's onDestroy method

2011-05-18 Thread Henrique Boregio
Hi, in my Wicket Application class, I create a couple of thread that
sleep most of the time..and come alive every one in a while to do some
maintenance tasks.

I create them in the init() method of the Wicket Application...and
call kill() on them in the onDestroy() method.

When I shutdown tomcat and restart it again (via the default .bat or
.sh), I can see from my log files that some threads from the previuos
deploy are still hanging around in memory.

Am I doing something wrong?

Many thanks.

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



Re: Killing threads in Application's onDestroy method

2011-05-18 Thread Henrique Boregio
My bad...that's actually what I am doing.
I have a stop() method insite my threads that change a boolean value
to false inside the while...instead of having while(tru)

On Wed, May 18, 2011 at 3:51 PM, Henrique Boregio hbore...@gmail.com wrote:
 Hi, in my Wicket Application class, I create a couple of thread that
 sleep most of the time..and come alive every one in a while to do some
 maintenance tasks.

 I create them in the init() method of the Wicket Application...and
 call kill() on them in the onDestroy() method.

 When I shutdown tomcat and restart it again (via the default .bat or
 .sh), I can see from my log files that some threads from the previuos
 deploy are still hanging around in memory.

 Am I doing something wrong?

 Many thanks.


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



Re: New Website up using wicket

2011-05-16 Thread Henrique Boregio
Actually, I didn't even know there was an html compressor for wicket
(I'll google it).

As for the other question, the backend runs on hibernate. Not 100%
hibernate, since I'm actually not mapping all of the relations using
hibernate.

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



New Website up using wicket

2011-05-12 Thread Henrique Boregio
Hey, just wanted to let you guys know that with the help of this
community, I was able to build my first real website using wicket.

Thanks everyone for the support in always trying answering the
questions I've answered. I look forward to using wicket in other
projects.

Oh, its spekios.com if anyone is interested. Thanks once again :)

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



Clean URLs in PagingNavigator

2011-05-07 Thread Henrique Boregio
Hi, I've implemented different coding strategies throughout my site to
have clean/good-looking URLs.

There are some places though, where I'm not able to clean them. For
example, when using a PagingNavigator..when I click on the default
links such as next, prev, etc...I am still getting the
?wicket:interface=:1:1::: attacked to the URL.

Anyone solved this before?

Many thanks.

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



Separate log files (tomcat, hibernate, wicket, etc)

2011-05-06 Thread Henrique Boregio
Hi, I've been searching for a simple way to do this but if I've only
found over-complicated tutorials.

I am trying to setup my lo4j properties file to do something like:

everything wicket -- wicket.log
everything hibernate -- hibernate.log
everything my_web_app -- my_app.log
everything tomcat -- tomcat.log

Anyone already have something like this setup?

Many thanks once again.

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



Re: Separate log files (tomcat, hibernate, wicket, etc)

2011-05-06 Thread Henrique Boregio
It asks how to redirect all of wicket logging to a separate log file
other then the application's log file.
So, this is a wicket question.

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



Re: Separate log files (tomcat, hibernate, wicket, etc)

2011-05-06 Thread Henrique Boregio
Fine..majority wins, it's a log4j question haha

Thanks anyways for the tips.

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



Initializing new thread in WicketApplication.init()

2011-05-03 Thread Henrique Boregio
Hi, I have a very simple thread that sleeps most of the time. Every
hour, it goes to the database to check what new stuff has been added,
and generates a summary of that.

This thread is started in my WicketApplication.init() method.

The problem is that the run() method of this thread, needs access to
the following method
WebApplication.get().getServletContext().getContextPath() but when
it tries to access this method, the following error occurs:

org.apache.wicket.WicketRuntimeException: There is no application
attached to current thread Thread

Any suggestions? Many thanks!

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



Re: Initializing new thread in WicketApplication.init()

2011-05-03 Thread Henrique Boregio
Thanks Martin...had to do some refactoring but your solution worked great.

On Tue, May 3, 2011 at 5:07 PM, Henrique Boregio hbore...@gmail.com wrote:
 Hi, I have a very simple thread that sleeps most of the time. Every
 hour, it goes to the database to check what new stuff has been added,
 and generates a summary of that.

 This thread is started in my WicketApplication.init() method.

 The problem is that the run() method of this thread, needs access to
 the following method
 WebApplication.get().getServletContext().getContextPath() but when
 it tries to access this method, the following error occurs:

 org.apache.wicket.WicketRuntimeException: There is no application
 attached to current thread Thread

 Any suggestions? Many thanks!


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



Re: Initializing new thread in WicketApplication.init()

2011-05-03 Thread Henrique Boregio
Actually..no, I hadn't thought about that.
Read up on how to kill threads and just finished implementing it. Thanks!



Also be sure to kill your thread in the application's onDestroy() otherwise
old threads will hang around if you do redeploys, but don't bounce the JVM.

You probably already thought of that. My scars are still fresh...

-Clint

On Tue, May 3, 2011 at 3:37 PM, Henrique Boregio hbor...@gmail.com wrote:

Thanks Martin...had to do some refactoring but your solution worked great.

On Tue, May 3, 2011 at 5:07 PM, Henrique Boregio hbor...@gmail.com
wrote:
Hi, I have a very simple thread that sleeps most of the time. Every
hour, it goes to the database to check what new stuff has been added,
and generates a summary of that.

This thread is started in my WicketApplication.init() method.

The problem is that the run() method of this thread, needs access to
the following method
WebApplication.get().getServletContext().getContextPath() but when
it tries to access this method, the following error occurs:

org.apache.wicket.WicketRuntimeException: There is no application
attached to current thread Thread

Any suggestions? Many thanks!

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

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



FileUpload size limit

2011-03-17 Thread Henrique Boregio
Hi, how can I restrict the size of a file being uploaded, before it gets
uploaded?

The following code does not work, since wicket first uploads the file to the
server, THEN checks its size (I've tried it uploading a 1Gig file):

   protected void onSubmit() {

final FileUpload upload = fileUploadField.getFileUpload();

if (upload != null) {
 if(upload.getSize()  Bytes.kilobytes(150).bytes()) {
 return;
 }
}
}


I've also tried setting the form's maxSize like so, but the file still seems
to get uploaded:
setMaxSize(Bytes.kilobytes(150));

Anyone run into this same problem? Thanks.


Before deployment checklist

2011-03-09 Thread Henrique Boregio
Hello. I am getting close to deploying my first wicket web
application. It's not huge but it does have lots of classes,
components, database stuff, search features, etc.

I was wondering if anyone had some kind of checklist on what things to
definitely check before deploying a wicket application into
production.

Thanks.

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



RestartResponseAtInterceptPageException not redirecting to source Page

2011-03-09 Thread Henrique Boregio
Hi, I have a RestartResponseAtInterceptPageException working correctly in
one case and not so in another.

I have a Login page with a LoginForm. In this form's onSubmit method, right
after the user validation takes place, I have:

if(!continueToOriginalDestination()) {
setResponsePage(Dashboard.class);
}

When this is called form the following Page, it works correctly (the users
gets redirected to the Login page, and once he logs in correctly, he is
redirected back to the page below):
public class PublishItem {
public PublishItem() {
if(!UserLoggedInSession.get().isLoggedIn()) {
UserLoggedInSession.get().getFeedbackMessages().add(getPage(), You need to
Sign in before you can publish!, FeedbackMessage.INFO);
throw new RestartResponseAtInterceptPageException(Login.class);
}
}
}

However, when this same logics is applied from within a Link's onClick
method, it does not work:
AnotherPage.java
Link signinLink = new Link(siginLink) {
public void onClick() {
UserLoggedInSession.get().getFeedbackMessages().add(getPage(), Signin
before adding a comment!, FeedbackMessage.INFO);
throw new RestartResponseAtInterceptPageException(Login.class);
}
};
signinLink.setVisible(!userLoggedIn);
add(signinLink);

In this second case, the user does get redirected to the Login page, and
once the correct username/password combination is entered, he actually logs
into the system. The problem is that the Login page simply refreshes, and
does not get redirected back to AnotherPage.java

Any help is appreciated.
Thanks.


Storing and loading escaped special characters.

2011-03-08 Thread Henrique Boregio
Hi, quick question.
Wicket automatically escapes special characters so when I type in:
This is my house.

What gets stored in my database is: This is quot;myquot; house

When I try to display it using a Label, like:
new Label(label, DAO.getValue(id));

It does not convert the quot; to quotes.

Is there a way to automatically do this or do I have to manually check
and convert everything?

Thanks.

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



Dynamic activity feed

2011-02-24 Thread Henrique Boregio
Hi, this is more of a design question than a wicket question, but I'm
sure someone has done it before.

Anyone has any idea if there are any simple libraries to create
activity feeds (like the one seen at http://www.bookrenter.com/ or the
Recent Activities column at http://www.9flats.com).

Right now I am using a ListView to statically display a few items, but
I would like to dynamically scroll through them, so it has a more
dynamic feel to it.

I am not looking for an AJAX component which constantly fetches new
items from the database, just to be able to have say about 15 items
loaded in the background and a 5-item window which scrolls through
them.

Thanks!

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



Re: Dynamic activity feed

2011-02-24 Thread Henrique Boregio
Hey Ernesto, I think this is exactly what I am looking for.
Will give it a try when I get home later today, thanks!

On Thu, Feb 24, 2011 at 11:24 AM, Henrique Boregio hbore...@gmail.com wrote:
 Hi, this is more of a design question than a wicket question, but I'm
 sure someone has done it before.

 Anyone has any idea if there are any simple libraries to create
 activity feeds (like the one seen at http://www.bookrenter.com/ or the
 Recent Activities column at http://www.9flats.com).

 Right now I am using a ListView to statically display a few items, but
 I would like to dynamically scroll through them, so it has a more
 dynamic feel to it.

 I am not looking for an AJAX component which constantly fetches new
 items from the database, just to be able to have say about 15 items
 loaded in the background and a 5-item window which scrolls through
 them.

 Thanks!


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



Re: Storing and retrieving user uploaded images

2011-02-19 Thread Henrique Boregio
Thanks everyone, I was able to fix it by doing:

When uploading a picture:
WebApplication.get().getServletContext().getRealPath() + / +
profilePics + /;

When retrieving a picture:
WebApplication.get().getServletContext().getContextPath() + / +
profilePics + / + userId + /;

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



Storing and retrieving user uploaded images

2011-02-18 Thread Henrique Boregio
Hi, I'm having trouble storing user uploaded images.

In my WicketApplication class, I setup a folder to store users
pictures, so I end up with a folder structure similar to this:
ROOT FOLDER
- user1_folder (pic1.jpg, pic2.jpg, etc...)
- user2_folder ( ... )
- ...

The issue I am having is that this folder is created at
src/main/java (I am using maven). When I run the application, the
Root actually becomes the webapp folder, so the relative path
changes.

How can I unify this folder so that its absolute path remains the same
no matter where it is called from?

My current solutions is to hard-code it like: /src/main/java +
userFolderName, but that's no the best way I'm sure.

Thanks!

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



Browser loading absolute image paths

2011-01-15 Thread Henrique Boregio
Hi, I am trying to load a picture from a user folder, so I am storing
the picture's path and pasting it into the src attribute of the
image tag.

As an example, I have the picture named profile.jpg located at
F:\workspace\project\pictures\2, so the corresponding HTML is:

img wicket:id=image src=F:\workspace\project\pictures\2\profile.jpg/

This picture exists and I can easily navigate to that folder using a
file browser, but it won't load from the browser.
How can I make the browser load absolute paths like this? Thanks.

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



Mixing links and texts

2011-01-10 Thread Henrique Boregio
Hello, I am working on a notifications systems and want to generate
notifications like the following:
UserX has asked you a question on item ItemY
Where UserX is a link to the user’s profile page. And ItemY is a link
to the item’s page.

Currently I am doing the following (pseudo-code):

Java Source Code:
Link userProfile Link= new Link(…)…
Label notificationText = new Label(“ has asked you a question on ítem “);
Link itemProfileLink = new Link(…)…

add(userProfileLink);
add(notificationText);
add(itemProfileLink);

HTML code:
a href=”#” wicket:id=”userProfileLink”/a
span wicket:id=”notificationText”/span
a href=”#” wicket:id=”itemProfileLink”/a

This works perfectly fine but it seems a bit like a waste of resources
creating 3 new objects for such a simple task. Am I missing some
feature un Wicket which allows this sort of behaviour?

Thanks.

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



Re: Mixing links and texts

2011-01-10 Thread Henrique Boregio
Making a custom component sounds like a good idea..thanks

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



Multiple user inputs created dynamically.

2011-01-05 Thread Henrique Boregio
Hello, I have a product published on a page, and users can ask the
owner of this product a question. Only the owner can then answer it.

A product can have many questions. But each question only has one
answer, which is answered by the owner.

What I am trying to do is have a listView listing all of the questions
users have made, and next to each one, a textField and a button for
the owner of the product to answer it.

So, it there are 5 unanswered questions, there would be 5 different
textFields with 5 different buttons next to it. The owner would then
have the choice to answer each one of them separately.

How can I develop this? Since I want the answer button only to refer
to the textField next to it, not the whole form, and I don't know
before hand how many textFields and buttons I will need. They would
have to be loaded dynamically, depending on the amount of new
questions that were made.

Thanks.

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



URL coding strategies

2010-12-16 Thread Henrique Boregio
Hello, I am mounting my URLs so I can list product items like so:
http://www.mysite.com/item/id/0
http://www.mysite.com/item/id/1

and so on...then I user this id param to fetch the data from the database.

I am not accesing this page directly. I have another page where the
items are fully listed (the item's title, description, price, etc) and
when the user click on each item, they are redirected to this /item/id
page.

Is there a way to avoid exposing the item's id, but send it behind
the scenes to the next page, so I would have something like:
http://www.mysite.com/item/ITEM_TITLE
eg. http://www.mysite.com/item/Ford-Ranger-Model-2005

In other words, I'm still using the item's id to fetch it from the
database, but the URL shows an SEO friendly version.

Thanks.

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



Re: URL coding strategies

2010-12-16 Thread Henrique Boregio
Hey Bas, you're right, I hadn't thought of it that way.

In option 1, how would I go about using a unique textual identifier?
Say there are 2 items with the name Ford Ranger Model 2005 but each
one is posted by different users, the URL would still be:
http://www.mysite.com/item/Ford-Ranger-Model-2005

..since no reference is made to the user, just to the item itself.

Is there a workaround this issue or do I need to make some kind of
reference to difference among items with the same title?
http://www.mysite.com/item/1-Ford-Ranger-Model-2005
http://www.mysite.com/item/2-Ford-Ranger-Model-2005
http://www.mysite.com/item/3-Ford-Ranger-Model-2005

Thanks.

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



Re: SQL Query casting objects

2010-12-10 Thread Henrique Boregio
Thanks, I'll give it a shot!

On Thu, Dec 9, 2010 at 11:39 PM, Henrique Boregio hbore...@gmail.com wrote:
 I have an SQL query to do a full-text search on my database:

 String sql = SELECT * FROM Items WHERE MATCH (title, description)
 AGAINST (' + searchText + ');;
 List items = session.createSQLQuery(sql).list();

 When I execute it, it returns a list with the rows it found as a result.
 Each row is actually an Item object, but since this is an SQL query,
 the result is an array of Objects.
 Is there a way to cast it to an Item object without having to
 manually go through each of the columns it returns?

 The same way an HQL automatically casts the results:
 ListItem items = (ListItem) session.createQuery( ... );

 I had no luck finding out how to implement sql MATCH and AGAINST using HQL.

 Does anyone know a solution to this issue? Thanks!




-- 
Henrique Boregio

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



Basic Webpage security

2010-12-10 Thread Henrique Boregio
Just like many others, my website has parts that are “public” and
parts where the user has to login to see it. Since I don’t need to
manage user roles, I have this basic interface:

public class SecureWebPage extends WebPage {
public SecureWebPage() {
if(!UserLoggedInSession.get().isLoggedIn()) {
getRequestCycle().setRedirect(true);
throw new RestartResponseException(Login.class);
}
}
}

So, if I have a webpage that is “private”, it just extends this
interface instead of the normal wicket Page.

My question is, just how safe is this approach to securing specific
individual webpages?
Could this security mechanism be easily broken and let non-loggedin users in?

Thanks.

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



Web search functionality

2010-12-09 Thread Henrique Boregio
I want to add search functionality to my site (think of a classifieds
site, something like craigslist where users post items to sell).

Currently I am using mysql for storage, and nothing else. Is searching
directly at the database via queries the best way? It seems illogical
to perform a linear search at a large mysql table using a 'like'
statement. I'm sure there's a better way, anyone implemented a
successful (fast, memory-friendly) search feature in a web 2.0 site?
Thanks.

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



SQL Query casting objects

2010-12-09 Thread Henrique Boregio
I have an SQL query to do a full-text search on my database:

String sql = SELECT * FROM Items WHERE MATCH (title, description)
AGAINST (' + searchText + ');;
List items = session.createSQLQuery(sql).list();

When I execute it, it returns a list with the rows it found as a result.
Each row is actually an Item object, but since this is an SQL query,
the result is an array of Objects.
Is there a way to cast it to an Item object without having to
manually go through each of the columns it returns?

The same way an HQL automatically casts the results:
ListItem items = (ListItem) session.createQuery( ... );

I had no luck finding out how to implement sql MATCH and AGAINST using HQL.

Does anyone know a solution to this issue? Thanks!

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



Markup's isVisible method being called multiple times

2009-04-18 Thread Henrique Boregio
I am overriding the link's onVisible method to do some conditional
markup. I've realized that this method is actually being call 4 times.
When I add a simple System.out to the following code, I get the
corresponding resut:


MyPAGE.JAVA

public class MyPage extends WebPage {
  public MyPage(final PageParameters parameters) {

add(new Link(link) {
public boolean isVisible() {
   System.out.println(here i am);
   return false;
}
}
  }
}

PAGE.HTML
htmlbody
a href=# wicket:id=linkThe Link/a
/body/html

RESULT
here i am
here i am
here i am
here i am

Any ideas why this method is being called 4 times?
Thanks.
-- 
Henrique Boregio

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



Passing hidden parameters / bookmarkable links

2009-04-15 Thread Henrique Boregio
I am developing a system that has groups and want to make them
accesible via user-friendly urls such as

www.mysite.com/group/GROUPNAME

On a web page, I have a list of groups which are all links to their
group pages, such as:
www.mysite.com/group/groupA
www.mysite.com/group/groupB
...

This is implemented as such:
PageParameters parameters = new PageParameters();
parameters.put(groupName, aGroup.getName());
add(new BookmarkablePageLink(groupName, GroupHomePage.class, parameters));

and also mounting a BookmarkablePage in my Wicket Application
mountBookmarkablePage(/groups, GroupHomePage.class);

and in my GroupHomePage class, I have:
public GroupHomePage (final PageParameters parameters) {

String groupName = parameters.getString(groupName);
int groupId = GroupDAO.getGroupId(groupName);
}

So as you can see, I basically retrieve the groupName and go fetch the
groupId from the database.
I already know the groupId from the page I was coming from so there is
no need to go back to the databse.

How can I pass this groupId parameter to GroupHomePage without
compromising the user-friendly links such as
www.mysite.com/group/groupName?
Thanks.

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



Refreshing page / onBeforeRender() issue

2009-04-12 Thread Henrique Boregio
I have a web page with a simple design where a NavigationPanel
contains a few links which replace the main panel with other panels.

My problem is that when I initialize this web page, it creates all of
the panels which will eventually replace a main panel (according to
the link in the NavigationPanel that the user has clicked) by calling
their constructors. Since the constructors initialize a bunch of
components and also retrieve data from a database, it takes a long
time to render the web page since it is also loading all of the other
panels.

Since I want to perform a kind of lazy loading (I only load the
components of the panels if the user has clicked on the corresponding
link in the NavigationPanel), I moved the code where I initialize the
components to the onBeforeRender() method instead of the constructor.
It worked fine for the first time I clicked a link but if I re-clicked
it, a wicket error would pop up since I was trying to add new
components that had already been added.

My solution was something like:

protected void onBeforeRender() {
  super.onBeforeRender();

  if(!firstTime) {
 return;
  }

  // create the components used in this panel
  ...
  firstTime = true
}


This way the components are created only if it is the first time I am
loading the panel.

My question is, is there a better or automatic way of doing this through wicket?
Thanks.

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