You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by BenHoit <be...@orange.com> on 2014/02/18 12:30:45 UTC

display XML in a popup (or another window) wicket 6.9.1

hi,
i want to display an xml string like with a ResourceLink
but i want this xml string to be uploaded from the database when i click on
the link.
before wicket 6.9.1 i used the DocumentInlineFrame from Ernesto Reinaldo
Barreiro and it works fine in a popup with a button ...
but with 6.9.1, i cant make it work.
Can someone help me ?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/display-XML-in-a-popup-or-another-window-wicket-6-9-1-tp4664527.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: display XML in a popup (or another window) wicket 6.9.1

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Do you want me to create an example and upload it to the repository? What
shout be the content? Any XML file/content?


On Tue, Feb 18, 2014 at 1:58 PM, BenHoit <be...@orange.com>wrote:

> so strange ...
> i put log in getString method (and in onResourceRequested of the
> DocumentInlineFrame).
> they are never called and my panel is filled with random xml.
> i also log the database request and the response (before calling new
> OdyReqTargetPanel) : they are correct
>
> public class OdyReqTargetPanel extends Panel {
>         private static final long serialVersionUID = 1L;
>         private static final Logger log =
> LoggerFactory.getLogger(OrdersPage.class.getName());
>
>         public OdyReqTargetPanel(String id,final byte[] res) {
>                 super(id);
>         //setRenderBodyOnly(true);
>         add(new DocumentInlineFrame("myxml",  new
> ResourceStreamResource(new
> AbstractStringResourceStream("text/xml") {
>                         @Override
>                         protected String getString() {
>                                 log.debug("ResourceStreamResource = ["+new
> String(res)+"]");
>                                 return new String(res);
>                         }
>                 })));
>         }
> }
>
> public class DocumentInlineFrame extends WebMarkupContainer implements
> IResourceListener
> {
>         private static final long serialVersionUID = 1L;
>
>         private static final Logger log =
> LoggerFactory.getLogger(OrdersPage.class.getName());
>
>         private IResource documentResource;
>
>         /**
>          *
>          * Constructor receiving an IResourceStream.
>          *
>          * @param id
>          * @param stream
>          */
>         public DocumentInlineFrame(String id, IResourceStream stream) {
>                 this(id, new ResourceStreamResource(stream));
>         }
>
>         /**
>          * Constructor receiving an IResource..
>          *
>          * @param id
>          * @param resourceListener
>          */
>         public DocumentInlineFrame(final String id, IResource
> documentResource)
>         {
>                 super(id);
>                 this.documentResource = documentResource;
>         }
>
>         /**
>          * Gets the url to use for this link.
>          *
>          * @return The URL that this link links to
>          */
>         protected CharSequence getURL()
>         {
>                 return urlFor(IResourceListener.INTERFACE, null);
>         }
>
>         /**
>          * Handles this frame's tag.
>          *
>          * @param tag
>          * the component tag
>          * @see org.apache.wicket.Component#onComponentTag(ComponentTag)
>          */
>         @Override
>         protected final void onComponentTag(final ComponentTag tag)
>         {
>                 checkComponentTag(tag, "iframe");
>
>                 // Set href to link to this frame's frameRequested method
>                 CharSequence url = getURL();
>
>                 // generate the src attribute
>                 tag.put("src", Strings.replaceAll(url, "&", "&amp;"));
>
>                 super.onComponentTag(tag);
>         }
>
>
>
>         @Override
>         protected boolean getStatelessHint()
>         {
>                 return false;
>         }
>
>         public void onResourceRequested() {
>                 log.debug("onResourceRequested =
> ["+this.documentResource+"]");
>                 RequestCycle requestCycle = RequestCycle.get();
>                 Attributes attributes = new
> Attributes(requestCycle.getRequest(),
> requestCycle.getResponse(), null);
>                 this.documentResource.respond(attributes);
>         }
> }
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/display-XML-in-a-popup-or-another-window-wicket-6-9-1-tp4664527p4664537.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Regards - Ernesto Reinaldo Barreiro

Re: display XML in a popup (or another window) wicket 6.9.1

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
That smell to client caching the resourse: try to add some random noise to
the URL


On Tue, Feb 18, 2014 at 2:06 PM, BenHoit <be...@orange.com>wrote:

> in fact not "never called" but sometimes called !!
> my button is in a DataView (there is one button per line). i also have a
> PagingNavigator
> if i change the page in the paging navigator, getString and
> onResourceRequested are sometimes called on the first click. but never
> after.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/display-XML-in-a-popup-or-another-window-wicket-6-9-1-tp4664527p4664540.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Regards - Ernesto Reinaldo Barreiro

Re: display XML in a popup (or another window) wicket 6.9.1

Posted by Timo Schmidt <wi...@xomit.de>.
On Tue 18.02.2014 05:33, BenHoit wrote:
>
> i think you are right because when i clean my browser cache
> between each click, it works every time !
> but, sorry, i don't know how to "Append some random noise to
> the URL (src attribute) in onComponentTag(ComponentTag tag)"

See Image#addAntiCacheParameter as an example.


  -Timo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: display XML in a popup (or another window) wicket 6.9.1

Posted by BenHoit <be...@orange.com>.
i think you are right because when i clean my browser cache between each
click, it works every time !
but, sorry, i don't know how to "Append some random noise to the URL (src
attribute) in onComponentTag(ComponentTag tag)"

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/display-XML-in-a-popup-or-another-window-wicket-6-9-1-tp4664527p4664544.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: display XML in a popup (or another window) wicket 6.9.1

Posted by Timo Schmidt <wi...@xomit.de>.
On Tue 18.02.2014 05:06, BenHoit wrote:
>
> in fact not "never called" but sometimes called !! my button
> is in a DataView (there is one button per line). i also
> have a PagingNavigator if i change the page in the paging
> navigator, getString and onResourceRequested are sometimes
> called on the first click. but never after.

This seems to be a caching issue. Append some random noise to
the URL (src attribute) in onComponentTag(ComponentTag tag).

  -Timo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: display XML in a popup (or another window) wicket 6.9.1

Posted by BenHoit <be...@orange.com>.
in fact not "never called" but sometimes called !!
my button is in a DataView (there is one button per line). i also have a
PagingNavigator
if i change the page in the paging navigator, getString and
onResourceRequested are sometimes called on the first click. but never
after.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/display-XML-in-a-popup-or-another-window-wicket-6-9-1-tp4664527p4664540.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: display XML in a popup (or another window) wicket 6.9.1

Posted by BenHoit <be...@orange.com>.
so strange ...
i put log in getString method (and in onResourceRequested of the
DocumentInlineFrame).
they are never called and my panel is filled with random xml.
i also log the database request and the response (before calling new
OdyReqTargetPanel) : they are correct 

public class OdyReqTargetPanel extends Panel {
	private static final long serialVersionUID = 1L;
	private static final Logger log =
LoggerFactory.getLogger(OrdersPage.class.getName());

	public OdyReqTargetPanel(String id,final byte[] res) {
		super(id);
        //setRenderBodyOnly(true);
        add(new DocumentInlineFrame("myxml",  new ResourceStreamResource(new
AbstractStringResourceStream("text/xml") {
			@Override
			protected String getString() {
				log.debug("ResourceStreamResource = ["+new String(res)+"]");
				return new String(res);
			}
		}))); 
	}
}

public class DocumentInlineFrame extends WebMarkupContainer implements
IResourceListener
{
	private static final long serialVersionUID = 1L;

	private static final Logger log =
LoggerFactory.getLogger(OrdersPage.class.getName());

	private IResource documentResource;

	/**
	 *
	 * Constructor receiving an IResourceStream.
	 *
	 * @param id
	 * @param stream
	 */
	public DocumentInlineFrame(String id, IResourceStream stream) {
		this(id, new ResourceStreamResource(stream));
	}

	/**
	 * Constructor receiving an IResource..
	 *
	 * @param id
	 * @param resourceListener
	 */
	public DocumentInlineFrame(final String id, IResource documentResource)
	{
		super(id);
		this.documentResource = documentResource;
	}

	/**
	 * Gets the url to use for this link.
	 *
	 * @return The URL that this link links to
	 */
	protected CharSequence getURL()
	{
		return urlFor(IResourceListener.INTERFACE, null);
	}

	/**
	 * Handles this frame's tag.
	 *
	 * @param tag
	 * the component tag
	 * @see org.apache.wicket.Component#onComponentTag(ComponentTag)
	 */
	@Override
	protected final void onComponentTag(final ComponentTag tag)
	{
		checkComponentTag(tag, "iframe");

		// Set href to link to this frame's frameRequested method
		CharSequence url = getURL();

		// generate the src attribute
		tag.put("src", Strings.replaceAll(url, "&", "&amp;"));

		super.onComponentTag(tag);
	}



	@Override
	protected boolean getStatelessHint()
	{	
		return false;
	}

	public void onResourceRequested() {
		log.debug("onResourceRequested = ["+this.documentResource+"]");
		RequestCycle requestCycle = RequestCycle.get();
		Attributes attributes = new Attributes(requestCycle.getRequest(),
requestCycle.getResponse(), null);
		this.documentResource.respond(attributes);
	}
}

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/display-XML-in-a-popup-or-another-window-wicket-6-9-1-tp4664527p4664537.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: display XML in a popup (or another window) wicket 6.9.1

Posted by Timo Schmidt <wi...@xomit.de>.
On Tue 18.02.2014 04:15, BenHoit wrote:
> i have tried it but i don't know how to replace the new
> PackageResourceStream(HomePage.class, "ScalaOverview.pdf")
> i haven't a resourceStream but a string (or a byte[])

Try this:

private final IResource resource;

/**
 * Constructor.
 * 
 * @param id ID of component
 *
 */
public AbstractXmlContentIframe(final String id) {
	super(id);

	resource = new ResourceStreamResource(new AbstractStringResourceStream("text/xml") {
		private static final long serialVersionUID = 1L;

		@Override
		protected String getString() {
			// Return your XML here
		}
	});
}


  -Timo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: display XML in a popup (or another window) wicket 6.9.1

Posted by BenHoit <be...@orange.com>.
i have tried it but i don't know how to replace the new
PackageResourceStream(HomePage.class, "ScalaOverview.pdf")
i haven't a resourceStream but a string (or a byte[])

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/display-XML-in-a-popup-or-another-window-wicket-6-9-1-tp4664527p4664532.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: display XML in a popup (or another window) wicket 6.9.1

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Hi,

Try this....

https://github.com/reiern70/antilia-bits/tree/master/content-iframe



On Tue, Feb 18, 2014 at 1:04 PM, BenHoit <be...@orange.com>wrote:

> in wicket 1.4, i used an IndicatingAjaxLink and in onClick method, i asked
> my
> database, get a String, transform it in a byte[] and used
> DocumentInlineFrame with an XmlResource class extended DynamicWebResource
>
> import org.apache.wicket.markup.html.DynamicWebResource;
>
> public class MyXmlResource extends DynamicWebResource {
>         private static final long serialVersionUID = 1L;
>     private byte[] myXml;
>
>     public MyXmlResource(byte[] thisXml) {
>         this.myXml = thisXml;
>     }
>
>     /* (non-Javadoc)
>      * @see
> org.apache.wicket.markup.html.DynamicWebResource#getResourceState()
>      */
>     @Override
>     protected ResourceState getResourceState() {
>         return new ResourceState() {
>
>             @Override
>             public String getContentType() {
>                 return "application/xml";
>             }
>
>             @Override
>             public byte[] getData() {
>                 try {
>                     return myXml;
>
>                 } catch (Exception e) {
>                     return null;
>                 }
>             }
>         };
>     }
>  }
>
> public class OdyReqTargetPanel extends Panel {
>         private static final long serialVersionUID = 1L;
>         public OdyReqTargetPanel(String id,byte[] res) {
>                 super(id);
>         //setRenderBodyOnly(true);
>         add(new DocumentInlineFrame("mypdf", new MyXmlResource(res)));
>         }
> }
>
> in wicket 6.9.1, DynamicWebResource doesn't exist any more ... and i don't
> know what i can use
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/display-XML-in-a-popup-or-another-window-wicket-6-9-1-tp4664527p4664530.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Regards - Ernesto Reinaldo Barreiro

Re: display XML in a popup (or another window) wicket 6.9.1

Posted by BenHoit <be...@orange.com>.
in wicket 1.4, i used an IndicatingAjaxLink and in onClick method, i asked my
database, get a String, transform it in a byte[] and used
DocumentInlineFrame with an XmlResource class extended DynamicWebResource

import org.apache.wicket.markup.html.DynamicWebResource;

public class MyXmlResource extends DynamicWebResource {
	private static final long serialVersionUID = 1L;
    private byte[] myXml;
 
    public MyXmlResource(byte[] thisXml) {
    	this.myXml = thisXml;
    }
 
    /* (non-Javadoc)
     * @see
org.apache.wicket.markup.html.DynamicWebResource#getResourceState()
     */
    @Override
    protected ResourceState getResourceState() {
        return new ResourceState() {
             
            @Override
            public String getContentType() {
                return "application/xml";
            }
             
            @Override
            public byte[] getData() {
                try {
                    return myXml;
                    
                } catch (Exception e) {
                    return null;
                }
            }
        };
    }
 }

public class OdyReqTargetPanel extends Panel {
	private static final long serialVersionUID = 1L;
	public OdyReqTargetPanel(String id,byte[] res) {
		super(id);
        //setRenderBodyOnly(true);
        add(new DocumentInlineFrame("mypdf", new MyXmlResource(res)));
	}
}

in wicket 6.9.1, DynamicWebResource doesn't exist any more ... and i don't
know what i can use


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/display-XML-in-a-popup-or-another-window-wicket-6-9-1-tp4664527p4664530.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: display XML in a popup (or another window) wicket 6.9.1

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
What's the problem you are facing?


On Tue, Feb 18, 2014 at 12:30 PM, BenHoit <be...@orange.com>wrote:

> hi,
> i want to display an xml string like with a ResourceLink
> but i want this xml string to be uploaded from the database when i click on
> the link.
> before wicket 6.9.1 i used the DocumentInlineFrame from Ernesto Reinaldo
> Barreiro and it works fine in a popup with a button ...
> but with 6.9.1, i cant make it work.
> Can someone help me ?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/display-XML-in-a-popup-or-another-window-wicket-6-9-1-tp4664527.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Regards - Ernesto Reinaldo Barreiro