0

Traditionally,all the java methods in XHTML code in Primefaces is of the form

<p:commandButton action="#{bean.variable}">

Is there another way to call java methods in XHTML code like

<p:commandButton action="#{bean.method()}">

I need to run the class below. I can use the @ManagedBean (and also use CDI and use @Named) but unsure how the method will be called even if i place a @PostConstruct on public void build(); Something is missing and i dont know how to fix it.

 public class SimpleReport_Step01 {

    public SimpleReport_Step01() {
        build();
}

private void build() {  
    try {
        report()//create new report design
          .columns(//add columns
            //            title,     field name     data type
            col.column("Item",       "item",      type.stringType()),
            col.column("Quantity",   "quantity",  type.integerType()),
            col.column("Unit price", "unitprice", type.bigDecimalType()))
          .title(cmp.text("Getting started"),cmp.horizontalList().add(
                      
                      cmp.hListCell(projectOverview()),
                      cmp.hListCell(projectStatus())       
                      ))//shows report title
          .pageFooter(cmp.pageXofY())//shows number of page at page footer
          .setDataSource(createDataSource())//set datasource
          .show();//create and show report
    } catch (DRException e) {
        e.printStackTrace();
    }
}
    
    private ComponentBuilder<?, ?> projectOverview(){
        HorizontalListBuilder hlb = cmp.horizontalList();
        hlb.add(cmp.text("max")).newRow();
        hlb.add(cmp.text("con")).newRow();
        hlb.add(cmp.text("fex")).newRow();
           return cmp.verticalList(cmp.text("PROJECT OVERVIEW"),hlb);}
    
     private ComponentBuilder<?, ?> projectStatus(){
        HorizontalListBuilder hlb = cmp.horizontalList();
        hlb.add(cmp.text("")).newRow();
        hlb.add(cmp.text("")).newRow();
        hlb.add(cmp.text("")).newRow();
           return cmp.verticalList(cmp.text("PROJECT STATUS"),hlb);}

private JRDataSource createDataSource() {
    DRDataSource dataSource = new DRDataSource("item", "quantity", "unitprice");
    dataSource.add("Notebook", 1, new BigDecimal(500));
    dataSource.add("DVD", 5, new BigDecimal(30));
    dataSource.add("DVD", 1, new BigDecimal(28));
    dataSource.add("DVD", 5, new BigDecimal(32));
    dataSource.add("Book", 3, new BigDecimal(11));
    dataSource.add("Book", 1, new BigDecimal(15));
    dataSource.add("Book", 5, new BigDecimal(10));
    dataSource.add("Book", 8, new BigDecimal(9));
    return dataSource;
}
}

I know this is a swing app and probably i can change it to run on the browser by using the usual jasper methods used like in this link

Afroid1000
  • 149
  • 10
  • Are you implying `` does not work? This is not PrimeFaces related by the way. – Jasper de Vries Jul 09 '21 at 09:23
  • 1
    Does this answer your question? [commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated](https://stackoverflow.com/questions/2118656/commandbutton-commandlink-ajax-action-listener-method-not-invoked-or-input-value) – Jasper de Vries Jul 09 '21 at 09:30
  • @Jasper: Nope, OP is basically asking how to run a desktop app from web app on. I think this is a better duplicate for his actual http://xyproblem.info: https://stackoverflow.com/q/9391838 – BalusC Jul 09 '21 at 11:26
  • @JasperdeVries yes, i have tried calling a method before and it failed.The link you provide is a real eye opener.@BalusC running a swing app in a web app is incidental.I would prefer not run it at all, which is a separate rabbit hole am in.Thanks all. – Afroid1000 Jul 10 '21 at 10:31
  • @BalusC the links are pure gold!! Although i knew running swing is a separate problem, i knew i would need to study **FaceContext** but unsure where to start. I hv been trying to manage an incredible learning curve of servlets,jsf,html,css,ajax,jquery and (some) javascript and its been a nightmare. I think i need to focus on JSF,..primefaces will start to feel natural.What do you think? – Afroid1000 Jul 10 '21 at 11:06

0 Answers0