Thanks,
Unfortunately, I am running out of time here. I'm packing my bags, and
after that have to go to Ji Jistu, and probably won't have time to look
at it tonight.
And tommorrow morning I fly to denver, where I will spend a week hiking
etc in the mountains, so I'll be cut off from internet access.
So, I hope my dear project collegues will take a look at your problem.
I'll be back on-line the 25th.
See ya,
Eelco
叶卫国 wrote:
Eelco Hillenius,
Of course. This is a page:
=======================================================================
package eshop.wicket.page;
import wicket.IFeedback;
import wicket.markup.html.form.RequiredTextField;
import wicket.markup.html.form.TextArea;
import wicket.markup.html.form.TextField;
import wicket.markup.html.form.upload.FileUpload;
import wicket.markup.html.form.upload.FileUploadField;
import wicket.markup.html.form.upload.UploadForm;
import wicket.markup.html.form.validation.EmailAddressPatternValidator;
import wicket.markup.html.form.validation.RequiredValidator;
import wicket.markup.html.panel.FeedbackPanel;
import wicket.model.CompoundPropertyModel;
import eshop.domain.Shop;
import eshop.service.ShopService;
import eshop.wicket.CustomWebPage;
import eshop.wicket.bean.FileUploadBean;
import eshop.wicket.component.Border;
import eshop.wicket.component.MenuBasic;
import eshop.wicket.validation.PhoneValidator;
import eshop.wicket.validation.PostcodeValidator;
public class BasicShop extends CustomWebPage
{
private ShopService shopService;
private FileUploadBean uploadBean;
private Shop shop;
public BasicShop()
{
shopService = (ShopService)locateBean("shopService");
uploadBean = (FileUploadBean)locateBean("uploadBean");
Long shopId = getCustomWebSession().getShopId();
shop = shopService.fetch(shopId);
FeedbackPanel feedback = new FeedbackPanel("feedback");
Border border = new Border("border");
border.add(feedback);
border.add(new FormInput("form", feedback));
border.add(new MenuBasic("menu"));
add(border);
}
private class FormInput extends UploadForm
{
private IFeedback feedback;
private FileUploadField logo;
public FormInput(String id, IFeedback feedback)
{
super(id, new CompoundPropertyModel(shop), feedback);
add(new RequiredTextField("id", Long.class));
add(new RequiredTextField("domain"));
add(new RequiredTextField("name"));
add(new
TextArea("description").add(RequiredValidator.getInstance()));
add(new RequiredTextField("email").add(new
EmailAddressPatternValidator()));
add(new RequiredTextField("address"));
add(new RequiredTextField("postcode").add(new
PostcodeValidator()));
add(new RequiredTextField("phone").add(new
PhoneValidator()));
add(new TextField("fax").add(new PhoneValidator()));
add(new RequiredTextField("title"));
add(new TextField("keywords"));
add(logo = new FileUploadField("logo"));
}
protected void onSubmit()
{
FileUpload logoUpload = logo.getFileUpload();
uploadBean.upload(logo.getFileUpload(), shop.getLogo());
shopService.update(shop);
info(getLocalizer().getString("success", this));
}
}
}
=======================================================================
and this is my base WebPage
public class CustomWebPage extends WebPage
{
public Object locateBean(String beanName)
{
CustomWebApplication application =
(CustomWebApplication)getApplication();
return application.locateBean(beanName);
}
public CustomWebSession getCustomWebSession()
{
return (CustomWebSession)getSession();
}
}
=======================================================================
and this is my WebApplication
public class CustomWebApplication extends WebApplication
{
private WebApplicationContext context;
public void init()
{
getPages().setHomePage(Home.class);
getSettings().setResourcePollFrequency(Duration.ONE_SECOND);
getSettings().setThrowExceptionOnMissingResource(false);
getSettings().setRenderStrategy(ApplicationSettings.REDIRECT_TO_BUFFER);
getSettings().setStripComments(true);
getSettings().setStripWicketTags(true);
getSettings().setDefaultBeforeDisabledLink("<span
class=\"disabled_link\">");
getSettings().setDefaultAfterDisabledLink("</span>");
getSettings().setCompressWhitespace(false);
getSettings().setAutomaticLinking(false);
}
public ISessionFactory getSessionFactory()
{
return new ISessionFactory()
{
public Session newSession()
{
return new
CustomWebSession(CustomWebApplication.this);
}
};
}
public Object locateBean(String beanName)
{
if (context == null)
context =
WebApplicationContextUtils.getWebApplicationContext(getWicketServlet()
.getServletContext());
return context.getBean(beanName);
}
}
======= 2005-06-17 22:50:47 :=======
Ah, ok... Hmmm... that's something to investigate, though I can't think
of something off the top of my head. Could you send some code to this list?
Eelco
叶卫国 wrote:
Eelco Hillenius,
But another problem occurs ... When I submit a form, it works, but when
i upload a file, the annoying LazyInitializationException jump out
======= 2005-06-17 22:42:47 :=======
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user
= = = = = = = = = = = = = = = = = = = =
叶卫国
[EMAIL PROTECTED]
2005-06-17
HS^甸殜X�'矈辵純娗(疥膉虌妠�j亘�+kj谞夒畨�羈澺"殭^秶钖Z0F啙櫔l糙趭m~婐j穁湑�"濟+櫕b藉瀖片镀j+xg瓃鳙守b�êw瀡�
z郓秼)y鏮j薬囤l⑶gr壙i貪卷〆∪�^鱦)蓃EG谦櫒x%娝V壣峨甔�(悍~娻zw瓎踚��鍔薼矉玵玷�咤娝l⺋)撸�"rG谦
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user