Fixed potential concurrent modification exception.

Image dialog not saving uploaded file to ad_image.
This commit is contained in:
Heng Sin Low 2008-12-05 16:07:12 +00:00
parent dbbca01f82
commit 7e0a2141bb
5 changed files with 22 additions and 6 deletions

View File

@ -269,7 +269,9 @@ public class WButtonEditor extends WEditor
if (Events.ON_CLICK.equals(event.getName())) if (Events.ON_CLICK.equals(event.getName()))
{ {
ActionEvent actionEvent = new ActionEvent(this, getColumnName(), Events.ON_CLICK); ActionEvent actionEvent = new ActionEvent(this, getColumnName(), Events.ON_CLICK);
for (ActionListener evtListener : actionListeners) ActionListener[] listeners = new ActionListener[0];
listeners = actionListeners.toArray(listeners);
for (ActionListener evtListener : listeners)
{ {
evtListener.actionPerformed(actionEvent); evtListener.actionPerformed(actionEvent);
} }

View File

@ -38,6 +38,7 @@ import org.zkoss.zk.ui.event.Events;
public class WDateEditor extends WEditor public class WDateEditor extends WEditor
{ {
private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE}; private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE};
@SuppressWarnings("unused")
private static final CLogger logger; private static final CLogger logger;
static static

View File

@ -30,6 +30,7 @@ import org.zkoss.zk.ui.event.Events;
public class WDatetimeEditor extends WEditor public class WDatetimeEditor extends WEditor
{ {
private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE}; private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE};
@SuppressWarnings("unused")
private static final CLogger logger; private static final CLogger logger;
static static

View File

@ -133,7 +133,9 @@ public class WEditorPopupMenu extends Menupopup implements EventListener
{ {
ContextMenuEvent menuEvent = new ContextMenuEvent(evt); ContextMenuEvent menuEvent = new ContextMenuEvent(evt);
for (ContextMenuListener listener : menuListeners) ContextMenuListener[] listeners = new ContextMenuListener[0];
listeners = menuListeners.toArray(listeners);
for (ContextMenuListener listener : listeners)
{ {
listener.onMenu(menuEvent); listener.onMenu(menuEvent);
} }

View File

@ -71,6 +71,17 @@ public class WImageDialog extends Window implements EventListener
// load data // load data
if (m_mImage == null) if (m_mImage == null)
m_mImage = MImage.get (Env.getCtx(), 0); m_mImage = MImage.get (Env.getCtx(), 0);
else
{
try {
AImage aImage = new AImage(m_mImage.getName(), m_mImage.getData());
image.setContent(aImage);
} catch (Exception e) {
log.log(Level.WARNING, "load image", e);
}
}
fileButton.setLabel(m_mImage.getName()); fileButton.setLabel(m_mImage.getName());
// imageLabel.setIcon(m_mImage.getIcon()); // imageLabel.setIcon(m_mImage.getIcon());
AEnv.showCenterScreen(this); AEnv.showCenterScreen(this);
@ -172,7 +183,6 @@ public class WImageDialog extends Window implements EventListener
} }
String fileName = imageFile.getName(); String fileName = imageFile.getName();
byte[] data = null;
// See if we can load & display it // See if we can load & display it
try try
@ -197,7 +207,7 @@ public class WImageDialog extends Window implements EventListener
// Save info // Save info
m_mImage.setName(fileName); m_mImage.setName(fileName);
m_mImage.setImageURL(fileName); m_mImage.setImageURL(fileName);
m_mImage.setBinaryData(data); m_mImage.setBinaryData(image.getContent().getByteData());
} // cmd_file } // cmd_file
/** /**