Hi,
I want to add a button under gridweb from where to download the gridweb stream or to the xls to a specific path, the method being implemented in a primefaces bean.
Is this possible?
Thank you!
Hi,
I want to add a button under gridweb from where to download the gridweb stream or to the xls to a specific path, the method being implemented in a primefaces bean.
Is this possible?
Thank you!
Could you please elaborate your requirements/issue more. What issue you are facing in your current scenario/case, share your sample code for reference. Do you need to render to XLSX (from GridWeb matrix) on a custom buttonâs click?
I attach the page here:
image.png (159.5 KB)
the bean method I want to call is:
image.png (44.3 KB)
The parameter gridweb is null, my question is how can I make this connection between these two, to call the bean function with gridweb as parameter
I guess if you need to obtain GridWeb data from a custom command button, you need to register your command button to sink events for getting GridWeb data. This is a line we can normally use on Page_Load event in ASP.NET, e.g.
Button1.Attributes["onclick"] = "GridWeb1.updateData(); return GridWeb1.validateAll();";
so, you may write parallel java code for it at some place where you do initialization for the objects/controls.
Can you please show me the Javascript code that the button calls, please?
Thank very much for your help!
we can achiev it through custom button,
here is .net version guide.
however ,there is a bug CELLSJAVA-44838 in java version when using custom command buttons.
We 've fixed it in v22.8.1 .
We will publish the java release version 22.9 in next month.
We will also update the demo in Github and add the java document guide
thank you,
but can it be achieved by adding an external button, not as component in the grid, just on the page? and after get the right instance of the GridWebBean to have the gridweb object in java class?
Ok, we will get back to you to provide assistance on achieving your task via external command button.
in page:add a button to trigger js:
//here mycomponent is the gridweb div id ,the second parameter ,just use false is ok
//get gridweb instance and call postBack function
document.getElementById(âmycomponentâ).postBack(âCCMD:helloâ,false);
in servlet
class MyCommandEventHandler implements CustomCommandEventHandler,Serializable{
private static final long serialVersionUID = 1L;
@Override
public void handleCellEvent(Object sender, String command) {
GridWebBean gridweb = (GridWebBean) sender;
//do some thing here ďźand get command: hello will be printed
System.out.print("get command:"+command+" "+gridweb.getActiveSheet().getName());
gridweb.getActiveSheet().getCells().get("F9").putValue(command);
}
}
gridweb.CustomCommand=new MyCommandEventHandler();
Here I have my java class:
public class SaveGridWebServlet implements CustomCommandEventHandler,Serializable{
private static final long serialVersionUID = 1L;
@Override
public void handleCellEvent(Object sender, String command) {
GridWebBean gridweb = (GridWebBean) sender;
//do some thing here ďźand get command: hello will be printed
System.out.print(âget command:â+command+" "+gridweb.getActiveSheet().getName());
gridweb.getActiveSheet().getCells().get(âF9â).putValue(command);
}
// gridweb.CustomCommand=new SaveGridWebServlet();
}
this is how I called it from the button:
It does not seem to call the method when clicking on the button. Have I added it wrongly?
thank you for your support!
please provide your page file.
only normal html button is enough, do not use p:commandButton
just something like:
<button onclick=âdocument.getElementById(âgridwebâ).postBack('CCMD:helloâ,false);console.log('click happen');â>test save</button>
it does not need any form.
This is my page file, it is an .xhtml file.
<f:view xmlns=âXHTML namespaceâ
xmlns:ui=âOracle Java Technologies | Oracleâ
xmlns:f=âOracle Java Technologies | Oracleâ
xmlns:h=âOracle Java Technologies | Oracleâ
xmlns:custom=âhttp://siemens.com/jsf/component/tags
â
xmlns:p=âUI Kit Licenses â PrimeFacesâ contentType=âtext/htmlâ
locale=â#{identity.locale}â>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<h:head>
<link rel="stylesheet" type="text/css" href="grid/acw_client/menu.css" />
<link rel="stylesheet" type="text/css" href="Scripts/jquery-ui.css" />
<script src="grid/acw_client/acwmain.js" type="text/javascript"></script>
<script src="grid/acw_client/lang_en.js" type="text/javascript"></script>
<script src="Scripts/jquery-2.1.1.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui.js" type="text/javascript"></script>
<script src="grid/acw_client/jquery-1.7.2.min.js"
type="text/javascript"></script>
<script>
function doClick(method) {
$.post("FunctionServlet", {
flag : method.id,
gridwebuniqueid : $("#mycomponent").attr("webuniqueid")
}, function(data) {
$("#Stylemycomponent").remove();
$("#gridweb").html(data);
}, "html");
}
$(document).ready(function() {
//loadHead();//
var method = {
id : "autoFilter"
};
doClick(method);
});
</script>
</h:head>
<h:body>
<div id="gridweb"></div>
<h:form id="gridwebForm"
onkeypress="if (event.keyCode == 13) { return false; }">
<p:commandButton value="Back" action="#{nodesBean.backHome}" styleClass="gridwebButton"
process="@this" />
<p:commandButton value="Save" onclick="document.getElementById('gridweb').postBack('CCMD:hello',false);" styleClass="gridwebButton"
process="@this" />
</h:form>
</h:body>
</f:view>
In your page gridweb div id is: mycomponent
so you need to write : document.getElementById(âmycomponentâ).postBack('CCMD:helloâ,false);
<div id="gridweb"></div>
<button onclick=âdocument.getElementById(âmycomponentâ).postBack('CCMD:helloâ,false);console.log('click happen');â>test save</button>
Tried this way, thank you, on browser console it is printed the âclick happennedâ text, but on the server side, the java method is not called
springdemo.zip (858.2 KB)
open and run the project
navigate to
http://localhost:8080/gridwebdemo/commandbutton
uncheck âshow save buttonâ
then click the " test button"
Hi Peter,
I have a question: with what version of aspose-cells should I try it in order to work?
Thank you very much for help!