Re: Adding to response header (filename)?

2007-10-07 Thread Stanczak Group
I've changed it to that below, but still get 18:22:47,185 ERROR 
WebResponse:190 - Unable to redirect to: ?wicket:interface=:2, HTTP 
Response has already been committed. in the logs. Isn't this the same 
as what's in the link you posted? I can post all the code, but all it is 
is a Link inside a Form. The code before what I've posted below simple 
appends text to the out, which is a StringBuilder. This is the only part 
where I send the request. I'm using 1.3 Wicket, and Apache Tomcat 6, if 
that helps.


SimpleDateFormat formatFile = new SimpleDateFormat(MM-dd-);
ResourceStreamRequestTarget rsrt = new ResourceStreamRequestTarget(new 
StringResourceStream(out, text/csv));
rsrt.setFileName(export_ + 
formatFile.format(Calendar.getInstance().getTime()) + .csv);

getRequestCycle().setRequestTarget(rsrt);






Jan Kriesten wrote:

hi,

see here:

http://www.nabble.com/Download-link-from-DynamicWebResource--tf4353363.html#a12404601

regards, --- jan.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Adding to response header (filename)?

2007-10-06 Thread Stanczak Group
Well, I still don't see a way to get around this error. I'll have to 
live with it for now until I can look into it deeper. Has anyone else 
had this error?


Stanczak Group wrote:
Instead of setRequestTarget(rsrt) I use this 
rsrt.respond(getRequestCycle());, is that correct? It does work, but 
I get this in the logs 08:53:03,277 ERROR WebResponse:190 - Unable to 
redirect to: ?wicket:interface=:2, HTTP Response has already been 
committed.. It works, but I wouldn't mind fixing that error, just to 
keep things clean.



Johan Compagner wrote:

or something like this:

new Link()
{
onclick()
{
CharSequence discounts = DataBase.getInstance()
   .exportDiscounts();


ResourceStreamRequestTarget rsrt = new ResourceStreamRequestTarget(new
StringResourceStream(discounts, text/csv));
rsrt.setFileName(name);
setRequestTarget(rsrt)
}
}

Maybe we should give ResourceStreanRequestTarget 1 extra constructor 
with

the file name..

 setRequestTarget(new ResourceStreamRequestTarget(new
StringResourceStream(discounts, text/csv,name)))


On 10/5/07, Eelco Hillenius [EMAIL PROTECTED] wrote:
 

On 10/5/07, Eelco Hillenius [EMAIL PROTECTED] wrote:
   

What do you use for the export? You probably should use a resource.
For instance:

public class DiscountsExport extends WebResource {

  public static class Initializer implements IInitializer {

public void init(Application application) {
  SharedResources res = application.getSharedResources();
  res.add(discounts, new DiscountsExport());
}
  }

  public DiscountsExport() {

setCacheable(false);
  }

  @Override
  public IResourceStream getResourceStream() {
CharSequence discounts = DataBase.getInstance().exportDiscounts();
return new StringResourceStream(discounts, text/plain);
  }

  @Override
  protected void setHeaders(WebResponse response) {
super.setHeaders(response);
response.setAttachmentHeader(discounts.csv);
  }
}
  

Sorry, this might be easier to understand:

   WebResource export = new WebResource() {

 @Override
 public IResourceStream getResourceStream() {
   CharSequence discounts = DataBase.getInstance()
   .exportDiscounts();
   return new StringResourceStream(discounts, text/csv);
 }

 @Override
 protected void setHeaders(WebResponse response) {
   super.setHeaders(response);
   response.setAttachmentHeader(discounts.csv);
 }
   };
   export.setCacheable(false);

   add(new ResourceLink(exportLink, export));


Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





  




--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Yanıt: Re: Adding to response header (filename)?

2007-10-06 Thread Stanczak Group
That's what I used to use, but it gives the same error. Do you not get 
the error in the logs. The error doesn't stop it from working, but I 
still would like to do it correctly according to Wicket.


Ramazan Pekin wrote:

I dont know the subject, I didnt follow up, but this code is working.
   
  downloadLink = new Link(downloadFile){

 private static final long serialVersionUID = 1L;
 public void onClick(){
  String tableCode = sourceCode;
  BufferedInputStream bis = null;
  BufferedOutputStream bos = null;
  try {
   String ContentType = text;
   getResponse().setContentType(ContentType);
   ((WebResponse)getResponse()).setHeader(Content-Disposition,inline; 
filename=\+fileName+.java\);
   ByteArrayInputStream bais = new ByteArrayInputStream(tableCode.getBytes());
   bis = new BufferedInputStream(bais);
   bos=new BufferedOutputStream(getResponse().getOutputStream());
   byte[] buff=new byte[2048];
   int bytesread;
   while((bytesread=bis.read(buff,0,buff.length)) != -1) {
bos.write(buff,0,bytesread);
   }
   bos.flush();
  } catch (Exception e) {
   e.printStackTrace();
  } finally{
   try {
bos.close();bos=null;
bis.close();bis=null;
   } catch (Exception e) {

   }

  }
 }
};

Eelco Hillenius [EMAIL PROTECTED] wrote:
  On 10/6/07, Stanczak Group wrote:
  

Well, I still don't see a way to get around this error. I'll have to
live with it for now until I can look into it deeper. Has anyone else
had this error?



But you shouldn't call respond yourself. That's for Wicket to do. The
only thing you should do is the the request target on the request
cycle.

Eelco

  

Stanczak Group wrote:


Instead of setRequestTarget(rsrt) I use this
rsrt.respond(getRequestCycle());, is that correct? It does work, but
I get this in the logs 08:53:03,277 ERROR WebResponse:190 - Unable to
redirect to: ?wicket:interface=:2, HTTP Response has already been
committed.. It works, but I wouldn't mind fixing that error, just to
keep things clean.


Johan Compagner wrote:
  

or something like this:

new Link()
{
onclick()
{
CharSequence discounts = DataBase.getInstance()
.exportDiscounts();


ResourceStreamRequestTarget rsrt = new ResourceStreamRequestTarget(new
StringResourceStream(discounts, text/csv));
rsrt.setFileName(name);
setRequestTarget(rsrt)
}
}

Maybe we should give ResourceStreanRequestTarget 1 extra constructor
with
the file name..

setRequestTarget(new ResourceStreamRequestTarget(new
StringResourceStream(discounts, text/csv,name)))


On 10/5/07, Eelco Hillenius wrote:



On 10/5/07, Eelco Hillenius wrote:

  

What do you use for the export? You probably should use a resource.
For instance:

public class DiscountsExport extends WebResource {

public static class Initializer implements IInitializer {

public void init(Application application) {
SharedResources res = application.getSharedResources();
res.add(discounts, new DiscountsExport());
}
}

public DiscountsExport() {

setCacheable(false);
}

@Override
public IResourceStream getResourceStream() {
CharSequence discounts = DataBase.getInstance().exportDiscounts();
return new StringResourceStream(discounts, text/plain);
}

@Override
protected void setHeaders(WebResponse response) {
super.setHeaders(response);
response.setAttachmentHeader(discounts.csv);
}
}



Sorry, this might be easier to understand:

WebResource export = new WebResource() {

@Override
public IResourceStream getResourceStream() {
CharSequence discounts = DataBase.getInstance()
.exportDiscounts();
return new StringResourceStream(discounts, text/csv);
}

@Override
protected void setHeaders(WebResponse response) {
super.setHeaders(response);
response.setAttachmentHeader(discounts.csv);
}
};
export.setCacheable(false);

add(new ResourceLink(exportLink, export));


Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



  


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



   
-

Yahoo! kullaniyor musunuz?
Istenmeyen postadan biktiniz mi? Istenmeyen postadan en iyi korunma Yahoo! 
Posta'da
http://tr.mail.yahoo.com
  


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Adding to response header (filename)?

2007-10-06 Thread Stanczak Group

Oh, then what should I do? Sorry if I'm missing the obvious here.

Eelco Hillenius wrote:

On 10/6/07, Stanczak Group [EMAIL PROTECTED] wrote:
  

What do you mean? This is all I'm doing, but still get the HTTP
Response has already been committed. error. Is there something there
that wrong?

SimpleDateFormat formatFile = new SimpleDateFormat(MM-dd--HH-MM);
ResourceStreamRequestTarget rsrt = new
ResourceStreamRequestTarget(new StringResourceStream(out, text/csv));
rsrt.setFileName(export_ +
formatFile.format(Calendar.getInstance().getTime()) + .csv);
rsrt.respond(getRequestCycle());



This last line, rsrt.respond is what you shouldn't do.

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Adding to response header (filename)?

2007-10-05 Thread Stanczak Group
, Eelco Hillenius [EMAIL PROTECTED] wrote:


What do you use for the export? You probably should use a resource.
For instance:

public class DiscountsExport extends WebResource {

  public static class Initializer implements IInitializer {

public void init(Application application) {
  SharedResources res = application.getSharedResources();
  res.add(discounts, new DiscountsExport());
}
  }

  public DiscountsExport() {

setCacheable(false);
  }

  @Override
  public IResourceStream getResourceStream() {
CharSequence discounts = DataBase.getInstance().exportDiscounts();
return new StringResourceStream(discounts, text/plain);
  }

  @Override
  protected void setHeaders(WebResponse response) {
super.setHeaders(response);
response.setAttachmentHeader(discounts.csv);
  }
}
  

Sorry, this might be easier to understand:

   WebResource export = new WebResource() {

 @Override
 public IResourceStream getResourceStream() {
   CharSequence discounts = DataBase.getInstance()
   .exportDiscounts();
   return new StringResourceStream(discounts, text/csv);
 }

 @Override
 protected void setHeaders(WebResponse response) {
   super.setHeaders(response);
   response.setAttachmentHeader(discounts.csv);
 }
   };
   export.setCacheable(false);

   add(new ResourceLink(exportLink, export));


Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





  


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Adding to response header (filename)?

2007-10-05 Thread Stanczak Group
Instead of setRequestTarget(rsrt) I use this 
rsrt.respond(getRequestCycle());, is that correct? It does work, but I 
get this in the logs 08:53:03,277 ERROR WebResponse:190 - Unable to 
redirect to: ?wicket:interface=:2, HTTP Response has already been 
committed.. It works, but I wouldn't mind fixing that error, just to 
keep things clean.



Johan Compagner wrote:

or something like this:

new Link()
{
onclick()
{
CharSequence discounts = DataBase.getInstance()
   .exportDiscounts();


ResourceStreamRequestTarget rsrt = new ResourceStreamRequestTarget(new
StringResourceStream(discounts, text/csv));
rsrt.setFileName(name);
setRequestTarget(rsrt)
}
}

Maybe we should give ResourceStreanRequestTarget 1 extra constructor with
the file name..

 setRequestTarget(new ResourceStreamRequestTarget(new
StringResourceStream(discounts, text/csv,name)))


On 10/5/07, Eelco Hillenius [EMAIL PROTECTED] wrote:
  

On 10/5/07, Eelco Hillenius [EMAIL PROTECTED] wrote:


What do you use for the export? You probably should use a resource.
For instance:

public class DiscountsExport extends WebResource {

  public static class Initializer implements IInitializer {

public void init(Application application) {
  SharedResources res = application.getSharedResources();
  res.add(discounts, new DiscountsExport());
}
  }

  public DiscountsExport() {

setCacheable(false);
  }

  @Override
  public IResourceStream getResourceStream() {
CharSequence discounts = DataBase.getInstance().exportDiscounts();
return new StringResourceStream(discounts, text/plain);
  }

  @Override
  protected void setHeaders(WebResponse response) {
super.setHeaders(response);
response.setAttachmentHeader(discounts.csv);
  }
}
  

Sorry, this might be easier to understand:

   WebResource export = new WebResource() {

 @Override
 public IResourceStream getResourceStream() {
   CharSequence discounts = DataBase.getInstance()
   .exportDiscounts();
   return new StringResourceStream(discounts, text/csv);
 }

 @Override
 protected void setHeaders(WebResponse response) {
   super.setHeaders(response);
   response.setAttachmentHeader(discounts.csv);
 }
   };
   export.setCacheable(false);

   add(new ResourceLink(exportLink, export));


Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





  


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: RequestCycle?

2007-10-04 Thread Stanczak Group
I'm not for sure what to use. I tried to override the newRequestCycle() 
but I had trouble understanding it. I'm doing something like what 
DataBinder does, but with 1.3. DataBinder seems to be 1.2. Either way 
I'd rather use my own. Does anyone have an example of providing my own 
request cycle, or is there an easier way?


Sam Hough wrote:

I think it is setup with ThreadLocal so you can get it easily with
RequestCycle.get(). You can also provide your own version from
Application.newRequestCycle which might be more what you need to hook in
start/end events.



Stanczak Group wrote:
  
How can I access the request cycle so I can open and close a Hibernate 
session on each request?


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do
nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






  


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: RequestCycle?

2007-10-04 Thread Stanczak Group
If I create my own request cycle, then what class do I extend? 
RequestCycle, WebRequestCycle or... ? RequestCycle requires you to 
implement other methods? Is there a wrapper class?


Stanczak Group wrote:
I'm not for sure what to use. I tried to override the 
newRequestCycle() but I had trouble understanding it. I'm doing 
something like what DataBinder does, but with 1.3. DataBinder seems to 
be 1.2. Either way I'd rather use my own. Does anyone have an example 
of providing my own request cycle, or is there an easier way?


Sam Hough wrote:

I think it is setup with ThreadLocal so you can get it easily with
RequestCycle.get(). You can also provide your own version from
Application.newRequestCycle which might be more what you need to hook in
start/end events.



Stanczak Group wrote:
 
How can I access the request cycle so I can open and close a 
Hibernate session on each request?


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do
nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






  




--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: RequestCycle?

2007-10-04 Thread Stanczak Group
I see DataBinder is just casting them and using WebRequestCycle, is that 
the right way?


Stanczak Group wrote:
If I create my own request cycle, then what class do I extend? 
RequestCycle, WebRequestCycle or... ? RequestCycle requires you to 
implement other methods? Is there a wrapper class?


Stanczak Group wrote:
I'm not for sure what to use. I tried to override the 
newRequestCycle() but I had trouble understanding it. I'm doing 
something like what DataBinder does, but with 1.3. DataBinder seems 
to be 1.2. Either way I'd rather use my own. Does anyone have an 
example of providing my own request cycle, or is there an easier way?


Sam Hough wrote:

I think it is setup with ThreadLocal so you can get it easily with
RequestCycle.get(). You can also provide your own version from
Application.newRequestCycle which might be more what you need to 
hook in

start/end events.



Stanczak Group wrote:
 
How can I access the request cycle so I can open and close a 
Hibernate session on each request?


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do
nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






  






--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: RequestCycle?

2007-10-04 Thread Stanczak Group

Ok, thanks. This is what I did.

public class RequestCycleImpl extends WebRequestCycle {

   private Session hibernateSession;

   public RequestCycleImpl(Application application, Request request, 
Response response) {

   super(application, (WebRequest) request, response);
   }

   @Override
   protected void onBeginRequest() {
   this.hibernateSession = 
HibernateUtil.getSessionFactory().openSession();

   }

   @Override
   protected void onEndRequest() {
   if (this.hibernateSession != null) {
   this.hibernateSession.close();
   }
   }

   public Session getHibernateSession() {
   return hibernateSession;
   }
}

Eelco Hillenius wrote:

On 10/4/07, Stanczak Group [EMAIL PROTECTED] wrote:
  

How can I access the request cycle so I can open and close a Hibernate
session on each request?



In your application class:

@Override
public RequestCycle newRequestCycle(Request request, Response response)
{
return new WebRequestCycle(this, (WebRequest)request, response)
{
@Override
protected void onBeginRequest()
{
// open session
}

@Override
protected void onEndRequest()
{
// close session
}
};
}

If you use Spring for instance, you could just configure the hibernate
session filter that comes with it instead.

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Going back after save or cancel method?

2007-10-04 Thread Stanczak Group
I have a classic list and edit page setup. You select an object that you 
then pass to the edit page. My hang up is how to I return the user to 
the list page, if the list page took a constructor parameter so it knows 
what to list? In other words the list page has a constructor parameter, 
so how can I just send the user back to the list page in it last state?


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Going back after save or cancel method?

2007-10-04 Thread Stanczak Group

Great, thanks.

Martijn Dashorst wrote:

pubic class ListPage {
...
@override void onClick() {
setResponsePage(new EditPage(getModelObject(), ListPage.this));
}
}

public class EditPage {
private Page previousPage;
public EditPage(Foo edit, Page back) {
previousPage = back;

...
@override protected void onSubmit() {
setResponsePage(previousPage);
}
 }
}

On 10/4/07, Stanczak Group [EMAIL PROTECTED] wrote:
  

I have a classic list and edit page setup. You select an object that you
then pass to the edit page. My hang up is how to I return the user to
the list page, if the list page took a constructor parameter so it knows
what to list? In other words the list page has a constructor parameter,
so how can I just send the user back to the list page in it last state?

--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






  


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Javadocs download?

2007-10-04 Thread Stanczak Group
I can't seem to find a download versions of the javadocs, anyone know? 
Do I need to use maven?


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Javadocs download?

2007-10-04 Thread Stanczak Group

Thanks.

Igor Vaynberg wrote:

http://wicketstuff.org/maven/repository/org/apache/wicket/wicket/1.3.0-SNAPSHOT/

-igor


On 10/4/07, Stanczak Group [EMAIL PROTECTED] wrote:
  

I can't seem to find a download versions of the javadocs, anyone know?
Do I need to use maven?

--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: More on Wicket/Hibernate...

2007-10-04 Thread Stanczak Group
It's really very simple. I'm doing the same thing here. You simple use 
the HibernateUtil example that is in the Hibernate documentation. Then 
you simple create a custom RequestCycle by overriding this method in 
your application. With the request cycle you can open and close 
Hibernate seesion. Then with a custom RequestCycle you can get it from 
anywhere, it uses thread local, and us it to access your database. 
Here's some example code:

##
   @Override
   public RequestCycle newRequestCycle(Request request, Response 
response) {

   return new RequestCycleImpl(this, request, response);
   }
##
public class RequestCycleImpl extends WebRequestCycle {

   private Session hibernateSession;

   public RequestCycleImpl(Application application, Request request, 
Response response) {

   super(application, (WebRequest) request, response);
   }

   @Override
   protected void onBeginRequest() {
   this.hibernateSession = 
HibernateUtil.getSessionFactory().openSession();

   }

   @Override
   protected void onEndRequest() {
   if (this.hibernateSession != null) {
   this.hibernateSession.close();
   }
   }

   public Session getHibernateSession() {
   return hibernateSession;
   }
}
##
public class AllDivisionModel extends LoadableDetachableModel {

   protected Object load() {
   Session session = ((RequestCycleImpl) 
RequestCycle.get()).getHibernateSession();

   Transaction tx = session.beginTransaction();
   try {
   @SuppressWarnings(value = unchecked)
   ListDivision results = (ListDivision) 
session.createCriteria(Division.class)

   .addOrder(Order.asc(name))
   .list();
   tx.commit();
   return results;
   } catch (Exception e) {
   Logger.getLogger(getClass()).error(e);
   tx.rollback();
   }
   return new ArrayList();
   }
}
##
   private boolean isLoggedIn(String username, String password) {
   Session session = ((RequestCycleImpl) 
getRequestCycle()).getHibernateSession();

   Transaction tx = session.beginTransaction();
   try {
   SysUser user = (SysUser) 
session.createCriteria(SysUser.class)

   .add(Restrictions.eq(username, username))
   .add(Restrictions.eq(password, password))
   .uniqueResult();
   if (!user.isLockout()) {
   return true;
   }
   tx.commit();
   } catch (Exception e) {
   Logger.getLogger(getClass()).error(e);
   tx.rollback();
   }
   return false;
   }
##

All that said, I'm pretty new my self, so I'm sure it can be improved. 
This seems to work so far for me.


Neil B. Cohen wrote:
I suspect I'm biting off more than I can chew conveniently but maybe 
someone can push me in the right direction...


I'm attempting to build a fairly simple web application with Wicket, 
and I'd like to use Hibernate to manage the database access (although 
other frameworks like Cayenne have been suggested and I'll look at 
them too...)


I think I've figured out the basic application structure, and how to 
map my data to an html page. But I don't think I understand the 
relationships between web sessions, hibernate sessions, DAO objects 
etc. I need to open a mysql db, read a set of objects from a table, 
and display them in a (paged) table on the screen. I've looked at 
several examples but they are using in-memory databases, or Spring 
along with Hibernate and I can't get a handle on what needs to be done 
to whom and by whom


Anyone have a really simple MySQL example like that? Or an online 
tutorial that I could follow?


Much obliged,

nbc

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



A button that does NOT submit form?

2007-10-04 Thread Stanczak Group
I don't want the cancel button to submit the form, is this the best 
method? I'm not sure I see how to do this. Is there examples?

@Override
   protected void delegateSubmit(IFormSubmittingComponent component) {
   }

--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: More on Wicket/Hibernate...

2007-10-04 Thread Stanczak Group
Another piece I forgot to add is the config and shutting down of the 
factory. I use this in the WebApplication:


   @Override
   protected void init() {
   try {
   HibernateUtil.setSessionFactory(new 
Configuration().configure().buildSessionFactory());

   } catch (Throwable e) {
   Logger.getLogger(getClass()).error(e);
   }
   }

   @Override
   protected void onDestroy() {
   HibernateUtil.getSessionFactory().close();
   }

Neil B. Cohen wrote:

Martijn Dashorst wrote:

According to me you can use Hibernate's thread local session if you
want (you still need the custom request cycle though!). This removes
the need for all the casting and getting.

Session.get().createCriteria(SysUser.class).add(.).uniqueResult();

Hibernate session, not Wicket's

Martijn


  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: A button that does NOT submit form?

2007-10-04 Thread Stanczak Group

Really new, but do you mean use the new Link() and input... ? Like this:

in code:
add(new Link(cancel){...});

in html:
input type=button wicket:id=cancel...

Like that?

Igor Vaynberg wrote:

best method is to add a Link to input type=button

-igor


On 10/4/07, Stanczak Group [EMAIL PROTECTED] wrote:
  

I don't want the cancel button to submit the form, is this the best
method? I'm not sure I see how to do this. Is there examples?
@Override
protected void delegateSubmit(IFormSubmittingComponent component) {
}

--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: A button that does NOT submit form?

2007-10-04 Thread Stanczak Group

Ah, yes. Link-O-Matic. Use the docs, that's what they're there for. Sorry.

Stanczak Group wrote:

Really new, but do you mean use the new Link() and input... ? Like this:

in code:
add(new Link(cancel){...});

in html:
input type=button wicket:id=cancel...

Like that?

Igor Vaynberg wrote:

best method is to add a Link to input type=button

-igor


On 10/4/07, Stanczak Group [EMAIL PROTECTED] wrote:
 

I don't want the cancel button to submit the form, is this the best
method? I'm not sure I see how to do this. Is there examples?
@Override
protected void delegateSubmit(IFormSubmittingComponent 
component) {

}

--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do 
nothing.

Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  




--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: RequestCycle?

2007-10-04 Thread Stanczak Group
Probably not. I'll probably use it when I get a chance. I just 
downloaded the 1.0 tar and saw it's using 1.2 Wicket. Shot me the link 
and I'll see if I can give it a shot tonight.


ChuckDeal wrote:

Stanczak Group wrote:
  
I'm not for sure what to use. I tried to override the newRequestCycle() 
but I had trouble understanding it. I'm doing something like what 
DataBinder does, but with 1.3. DataBinder seems to be 1.2. Either way 
I'd rather use my own. Does anyone have an example of providing my own 
request cycle, or is there an easier way?


Sam Hough wrote:


I think it is setup with ThreadLocal so you can get it easily with
RequestCycle.get(). You can also provide your own version from
Application.newRequestCycle which might be more what you need to hook in
start/end events.



Stanczak Group wrote:
  
  
How can I access the request cycle so I can open and close a Hibernate 
session on each request?


--
Justin Stanczak
Stanczak Group
812-735-3600



DataBinder (1.1-SNAPSHOT) definitely works with 1.3.  Databinder also does a
pretty good job of integrating Hibernate into the Wicket models.  Is there a
use case for which Databinder does not work for you?

Chuck
  


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Adding to response header (filename)?

2007-10-04 Thread Stanczak Group
How can I do this in Wicket? I'm writing a csv generated file to the 
output, but I don't know how to tell the client what file name to use. 
This is what I was using before, is there another way?


getResponse().setHeader(Content-Disposition, 
attachment;filename=\export_ + 
formatFile.format(Calendar.getInstance().getTime()) + .csv\);


Code##
   getResponse().setContentType(text/csv);
   
getResponse().setHeader(Content-Disposition, 
attachment;filename=\export_ + 
formatFile.format(Calendar.getInstance().getTime()) + .csv\);
   OutputStream cout = 
getResponse().getOutputStream();

   cout.write(out.toString().getBytes());
   cout.flush();
   cout.close();

--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wicket training:50% discount this weekend on next 3 bookings

2007-10-04 Thread Stanczak Group

Off you subject here, but is there any US training?

jweekend wrote:

The 2 day London  http://jweekend.co.uk/dev/JW703/ Wicket 1.3  course this
weekend still has plenty of room! Since it has been scheduled on demand and
without much notice, and to give people a chance who maybe wouldn't
otherwise get the opportunity to be professionally trained in Wicket, we are
offering a 50% discount to the next three people to 
http://jweekend.co.uk/dev/BookingPage/ book  a place.

You will also get your free licence to WiA MEAP.
Copy and paste this promotion code into your cart:
JW70310060750WU
Regards - Cemal
http://jWeekend.co.uk jWeekend.co.uk 

  


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Adding to response header (filename)?

2007-10-04 Thread Stanczak Group

This works:

getWebRequestCycle().getWebResponse().setContentType(text/csv);
   
getWebRequestCycle().getWebResponse().setHeader(Content-Disposition, 
attachment;filename=\export_ + 
formatFile.format(Calendar.getInstance().getTime()) + .csv\);
   OutputStream cout = 
getWebRequestCycle().getWebResponse().getOutputStream();

   cout.write(out.toString().getBytes());
   cout.flush();
   cout.close();

But I get this in the logs. How can I do this better?

16:31:45,391 ERROR WebResponse:190 - Unable to redirect to: 
?wicket:interface=:2, HTTP Response has already been committed.



Stanczak Group wrote:
This maybe? Should I be using getWebRequestCycle().getWebResponse() 
instead of getResponse().?

getWebRequestCycle().getWebResponse().setHeader()

Stanczak Group wrote:
How can I do this in Wicket? I'm writing a csv generated file to the 
output, but I don't know how to tell the client what file name to 
use. This is what I was using before, is there another way?


getResponse().setHeader(Content-Disposition, 
attachment;filename=\export_ + 
formatFile.format(Calendar.getInstance().getTime()) + .csv\);


Code## 


   getResponse().setContentType(text/csv);
   
getResponse().setHeader(Content-Disposition, 
attachment;filename=\export_ + 
formatFile.format(Calendar.getInstance().getTime()) + .csv\);
   OutputStream cout = 
getResponse().getOutputStream();

   cout.write(out.toString().getBytes());
   cout.flush();
   cout.close();





--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Adding to response header (filename)?

2007-10-04 Thread Stanczak Group
This maybe? Should I be using getWebRequestCycle().getWebResponse() 
instead of getResponse().?

getWebRequestCycle().getWebResponse().setHeader()

Stanczak Group wrote:
How can I do this in Wicket? I'm writing a csv generated file to the 
output, but I don't know how to tell the client what file name to use. 
This is what I was using before, is there another way?


getResponse().setHeader(Content-Disposition, 
attachment;filename=\export_ + 
formatFile.format(Calendar.getInstance().getTime()) + .csv\);


Code## 


   getResponse().setContentType(text/csv);
   
getResponse().setHeader(Content-Disposition, 
attachment;filename=\export_ + 
formatFile.format(Calendar.getInstance().getTime()) + .csv\);
   OutputStream cout = 
getResponse().getOutputStream();

   cout.write(out.toString().getBytes());
   cout.flush();
   cout.close();



--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Passing Values Between Pages?

2007-10-02 Thread Stanczak Group
New person question here. I just started using Wicket, but I don't 
understand how to pass values to other pages. Can't seem to find 
examples. Here's what I setup so far, but it doesn't seem to work. Just 
started using Wicket yesterday. Also, how do I put something in a 
application wide session. Like a login id?


   @Override
   protected void onSubmit() {
   StudentInformationPage page = new StudentInformationPage();
   page.setVisitDate(visitDate);
   setResponsePage(page);
   }

--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Using Hibernate in Wicket?

2007-10-02 Thread Stanczak Group
I'm using Hibernate with the HibernateUtil class. It all works except 
when I try to use the HibernateUtil in the Application.onDestroy() 
method. I want to have it close the factory when the server is shutdown. 
It's an embedded database so it's saying the database is locked. This 
looks to me like the Application is running in one thread and the Pages 
in another.  It's like the HibernateUtil static code is running twice. 
Is there a better way of using Hibernate in Wicket? Here's the code I'm 
using now.


###
public class HibernateUtil {

   private static final SessionFactory sessionFactory;
   static {
   try {
   // Create the SessionFactory from hibernate.cfg.xml
   sessionFactory = new 
Configuration().configure().buildSessionFactory();

   } catch (Throwable ex) {
   // Make sure you log the exception, as it might be swallowed
   System.err.println(Initial SessionFactory creation failed. 
+ ex);

   throw new ExceptionInInitializerError(ex);
   }...
#Application# 


 ...  @Override
   protected void onDestroy() {
   System.out.println(Killing database connection\n\n);
   HibernateUtil.getSessionFactory().close();
   }
###

--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using Hibernate in Wicket?

2007-10-02 Thread Stanczak Group
Thanks. They are pretty much doing the same as me. I found it was the 
IDE causing the issue. From some reason Tomcat is deploying it twice.


Igor Vaynberg wrote:

see databinder.net for ideas

-igor

On 10/2/07, Stanczak Group [EMAIL PROTECTED] wrote:
  

I'm using Hibernate with the HibernateUtil class. It all works except
when I try to use the HibernateUtil in the Application.onDestroy()
method. I want to have it close the factory when the server is shutdown.
It's an embedded database so it's saying the database is locked. This
looks to me like the Application is running in one thread and the Pages
in another.  It's like the HibernateUtil static code is running twice.
Is there a better way of using Hibernate in Wicket? Here's the code I'm
using now.


###
public class HibernateUtil {

private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new
Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println(Initial SessionFactory creation failed.
+ ex);
throw new ExceptionInInitializerError(ex);
}...

#Application#

  ...  @Override
protected void onDestroy() {
System.out.println(Killing database connection\n\n);
HibernateUtil.getSessionFactory().close();
}

###

--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do
nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





  


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Passing Values Between Pages?

2007-10-02 Thread Stanczak Group

Ok, thanks.

Igor Vaynberg wrote:

On 10/2/07, Stanczak Group [EMAIL PROTECTED] wrote:
  

Why would I need to override the WebSession? Can't I just use it as is?





the idea is that you add your typesafe properties and getters/setters into
your subclass. we do not provide a generic map for attributes like the
httpsession does.

-igor



  


--

  

Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do
nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




  

--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do
nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





  


--
Justin Stanczak
Stanczak Group
812-735-3600

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]