All pastes #490243 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-05-15 22:23 UTC
rendered paste body
public class Flash extends WebMarkupContainer  implements IResourceListener {


    private byte[] _flashBytes;
    private int _width;
    private int _height;
    
    /**
     * 
     * Constructs a new Flash.
     * 
     * @param id
     * @param flashResource
     * @param flashBytes
     */
    public Flash(String id, byte[] flashBytes, int width, int height) {
        super(id);

        setFlashBytes(flashBytes);
        setWidth(width);
        setHeight(height);
//        add(new FlashBody("flashBody", flashBytes));
//        add(new FlashParam("flashParam", flashBytes));
        
    }
    


    /**
     * (non-Javadoc)
     * @see org.apache.wicket.IResourceListener#onResourceRequested()
     */    
    public void onResourceRequested() {
        getRequestCycle().setRequestTarget(new IRequestTarget() {
            public void detach(RequestCycle requestCycle) { }

            public void respond(RequestCycle requestCycle) {
                Response r = requestCycle.getResponse();
                try {
                    r.getOutputStream().write(getFlashBytes());
                } catch (IOException e) {
                    throw RenRuntimeException.wrapWithRenRuntimeException(e);
                }
            }
        });
    }
          
    
    /* (non-Javadoc)
     * @see org.apache.wicket.Component#onComponentTagBody(org.apache.wicket.markup.MarkupStream, org.apache.wicket.markup.ComponentTag)
     */
    protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {

        super.onComponentTagBody(markupStream, openTag);
        StringBuffer flashBody = new StringBuffer();
        flashBody.append("<param name='movie' value='" + urlFor(IResourceListener.INTERFACE) + "'/>");
        flashBody.append("<param name='quality' value='high'/>");        
        flashBody.append("<embed src='"+urlFor(IResourceListener.INTERFACE)+"' width='" + getWidth() + "' height='" + getHeight() + "' ");
        flashBody.append("quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'></embed>");
        replaceComponentTagBody(markupStream, openTag, flashBody);
        //openTag.put("src",urlFor(IResourceListener.INTERFACE));
        
    }

 
    

    /**
     * Returns the height.
     *
     * @return the height
     */
    private int getHeight() {
        return _height;
    }

    /**
     * Sets the height.
     *
     * @param height the height
     */
    private void setHeight(int height) {
        _height = height;
    }

    /**
     * Returns the width.
     *
     * @return the width
     */
    private int getWidth() {
        return _width;
    }

    /**
     * Sets the width.
     *
     * @param width the width
     */
    private void setWidth(int width) {
        _width = width;
    }
    
    /**
     * Returns the flashBytes.
     *
     * @return the flashBytes
     */
    public byte[] getFlashBytes() {
        return _flashBytes;
    }

    /**
     * Sets the flashBytes.
     *
     * @param flashBytes the flashBytes
     */
    public void setFlashBytes(byte[] flashBytes) {
        _flashBytes = flashBytes;
    }

        
}