It's comparable to a reply I gave earlier today, which was:

   WebResource export = new WebResource() {

     @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");
     }
   };
   export.setCacheable(false);

   new ResourceLink(this, "exportLink", export);

Now, in your case, check out what ResourceLink does. You'll need about
the same, but only on another attribute. Your class would look
something like this:

public class Embed extends WebComponent implements IResourceListener
{
        private final Resource resource;

        public Embed(final String id, final Resource resource)
        {
                super(id);
                this.resource = resource;
        }

        protected void onComponentTag(ComponentTag tag)
        {
                super.onComponentTag(tag);

                // src == link to IResourceListener method on this
                tag.put("src", urlFor(IResourceListener.INTERFACE));
        }

        public final void onResourceRequested()
        {
                resource.onResourceRequested();
        }
}

As a side note - you probably already know this - the <embed> tag is
deprecated. It looks like <object> tags like this:

<object classid= "CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
type="audio/x-midi" width="145" height="120">
<param name="src" value="../files/softmelody.mid" />
</object>

are preferred?

Hope this helps,

Eelco


On 11/20/06, Roberto Muscillo <[EMAIL PROTECTED]> wrote:
> ...
> I've to  permit the upload of audio file; this files are stored in a
> particular directory on filesystem.
> Then I need to show in a webPage a <embed .. tag with the reference to the
> audio file uploaded.
>
> To do that, in the Audios.java,  I 've used an Audio.java ; this is a object
> similar to Image.java
> ...
> this is the code:
>
>         AudioUnit audioUnit = (AudioUnit) getModelObject();
>          String audioPaths = audioUnit.getAudioUrl().getFile(); // this get
> the path on filesystem
>
> Resource myResource = ....?????
>
> Audio myAudio = new Audio("unitAudio"), myResource);
> ...add(myAudio);
>
> the question is how can I get the Resource ???
> if was an image i could do something like:
>
>
>
>     public static Resource getImageResource(Class webpage, final String
> imageURL, String imageId) {
>
>         BufferedDynamicImageResource resource = new
> BufferedDynamicImageResource();
>         File imageFile = new File(imageURL);
>         BufferedImage image = null;
>         try {
>
>             image = ImageIO.read(imageFile);
>         }
>         catch (Exception e) {
>             log.error("newResource(): exception: " + e.getMessage());
>             log.error("newResource(): cause: " + e.getCause());
>         }
>         resource.setImage(image);
>
>         return resource;
>     }
>
>
>
> thanks for any help

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to