Can any one help on this issue?



---------- Forwarded message ----------
From: durairaj t <durairaj....@gmail.com>
Date: Fri, Dec 18, 2015 at 4:29 PM
Subject: Wicket migration 1.4 to 1.5.13 issue with WebmarkupContainer
/WebComponent/ByteArrayResource
To: users@wicket.apache.org


Hi Team -


How to change the below wicket version1.4 code to 1.5.13 , I tried
with WebComponent(String ,IModel<?> model), it doesn't work.

When I'm using the below code its placing the pdf content in the form
component but not in the WebmarkupContainer.
*getRequestCycle().scheduleRequestHandlerAfterCurrent(new
ResourceRequestHandler(byteArrayResource,null));*

Thanks for any help.

*xyzPage.java*
*------------------------------------------------------------------------------*

pdfPanel = new WebMarkupContainer("pdfPanel") {
public boolean isVisible() {
return irMode != IRMODE.EDIT;
}
};
pdfPanel.setOutputMarkupId(true);
pdfPanel.setMarkupId("pdfPanel");
pdfPanel.setOutputMarkupPlaceholderTag(true);
add(pdfPanel);

pdfPanel.add(new EmbeddedPDFComponent("pdfReport", null) {
/**
*
*/
private static final long serialVersionUID = 1L;
transient byte[] data = null;

public boolean isVisible() {
return irMode != IRMODE.EDIT;
}

@Override
public boolean showToolbar() {
return false;// irMode == IRMODE.PRINT;
}

public void onResourceRequested() {
DynamicWebResource pdfResource = new DynamicWebResource() {

/**
*
*/
private static final long serialVersionUID = 1L;

@Override
protected ResourceState getResourceState() {
// TODO Auto-generated method stub
return new ResourceState() {

@Override
public String getContentType() {
return "application/pdf";
}

@Override
public byte[] getData() {
if (data == null  {
try {
data = generatePdfIr();
refreshPrint = false;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return data;
}

};
}

};
pdfResource.onResourceRequested();

}
}.setOutputMarkupId(true).setMarkupId("pdfReport"));

moduleForm.ClearBooleanFlags();

}

*EmbeddedPDFComponent.java:*

public class EmbeddedPDFComponent extends WebComponent implements
IResourceListener
{

private static final long serialVersionUID = 1L;
protected final DynamicWebResource resource;

/**
* Construcxt.
*
* @param componentID
*            component componentID
* @param resource
*            the resource
*/
public EmbeddedPDFComponent(String componentID, DynamicWebResource resource)
{
super(componentID);
this.resource = resource;
}

/**
* @see wicket.IResourceListener#onResourceRequested()
*/
public void onResourceRequested()
{
resource.onResourceRequested();
}

/**
* @see wicket.Component#onComponentTag(wicket.markup.ComponentTag)
*/
protected void onComponentTag(ComponentTag tag)
{
if (!"object".equalsIgnoreCase(tag.getName()))
{
findMarkupStream().throwMarkupException(
"Component "
+ getId() + " must be applied to a tag of type 'object' not "
+ tag.toUserDebugString());
}
if(showToolbar())
tag.put("data",
getResponse().encodeURL(urlFor(IResourceListener.INTERFACE))+"#toolbar=1&statusbar=0&messages=0&navpanes="
+ (showNavPane()?"1":"0"));
else
tag.put("data",
getResponse().encodeURL(urlFor(IResourceListener.INTERFACE))+"#toolbar=0&statusbar=0&messages=0&navpanes="
+ (showNavPane()?"1":"0"));
tag.put("type","application/pdf");
super.onComponentTag(tag);
}
public boolean showToolbar(){
return false;
}
public boolean showNavPane(){
return false;
}
}

Reply via email to