Note that there are some explanatory texts on larger screens.

plurals
  1. POAction on JSF Drop Down Value
    primarykey
    data
    text
    <p>I have a JSF page, a drop down where values are getting fetched from service. </p> <pre><code>&lt;h:selectOneMenu id="valueList" value="#" style="height:20px;"&gt; &lt;f:selectItem itemValue="Select Action" itemLabel="Select Action" /&gt; &lt;f:selectItems value="#{sampleService.sampleMethod}" var="SampleExport" itemValue="#{SampleExport}" itemLabel="#{SampleExport}"&gt; &lt;/f:selectItems&gt; &lt;/h:selectOneMenu&gt; </code></pre> <p>exportlist contains - abc, xyz</p> <p><strong>sampleService class</strong></p> <pre><code>public class SampleServiceImpl implements .... { private List&lt;String&gt; sampleList; public List&lt;String&gt; getSampleList;() { return sampleList; } public void setSampleList;(List&lt;String&gt; sampleList;) { this.sampleList=sampleList;; } /** * Method for List to be displayed in drop down */ public void sampleMethod(){ if (sampleList== null) { sampleList = new ArrayList&lt;String&gt;(); sampleList.add("abc"); sampleList.add("xyz"); } setSsampleList(sampleList); } } </code></pre> <p>and there is an action button, which is used to generate a pdf based on the selection of type of value i.e. abc or xyz. </p> <p><strong>clicktoPdf button</strong></p> <pre><code>&lt;ui:define name="actions"&gt; &lt;h:commandButton styleClass="inputbutton" value="GeneratePdf" id="export" action="#{generatePdf.pdfReport}" style="float:right;width : 73px;" /&gt; &lt;/ui:define&gt; public class GeneratePdf { public void pdfReport() { .......... ...code.... HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet(); HSSFRow row = sheet.createRow(0); HSSFCell cell = row.createCell(0); .......... .code.......... methodAbc(){ ..... } method Xyz(){ ...... } FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext externalContext = facesContext.getExternalContext(); externalContext.setResponseContentType("application/vnd.ms-excel"); externalContext.setResponseHeader("Content-Disposition", "attachment; filename=\"Sample Report\""); workbook.write(externalContext.getResponseOutputStream()); facesContext.responseComplete(); } } </code></pre> <p>i need to generate pdf for the values selected from drop down. if "abc" is selected, it should call methodAbc(), if "xyz" is selected it should call methodXyz(). </p> <p>Also the drop down list could contain more values - abc,xyz,pqr,rst etc etc. I know its not feasible to add method for every value in the drop down. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload