Category Archives: Uncategorized

React Router 4 Nested Page

Hi;

Here is an example of nested pages in react router. So you can make a template page and create nested pages with same template easily with react..

index.php

<code>
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import { Route, BrowserRouter as Router, Switch} from 'react-router-dom';
import Template from './Template';
import ExamplePage1 from './Page1';
import ExamplePage2 from './Page2';
import Login from './Login';

ReactDOM.render(
  <Router>
    <div>
    <Switch>
      <Route exact path="/" component={Login}/>
      <Route exact path="/login" component={Login}/>
      <Template>
          <Route exact path="/page1" component={ExamplePage1}/>
          <Route exact path="/page2" component={ExamplePage2}/>
      </Template>
      </Switch>
    </div>
  </Router>,
  document.getElementById('root')
);

template.php

<code>
import React, { Component } from 'react';
import { withRouter } from 'react-router'
class Template extends Component {
  render() {
    return (
      <div>
        <div>Template</div>
        <div className="content">
          {this.props.children}
         </div>
      </div>

    );
  }
}

export default withRouter(Template);

You can find full example at : https://github.com/bbolek/react-router-template-example

Generic Excel Download in ZK Listbox


import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.zkoss.bind.annotation.AfterCompose;
import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.MouseEvent;
import org.zkoss.zul.Filedownload;
import org.zkoss.zul.ListModel;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listhead;
import org.zkoss.zul.Listheader;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.Messagebox.ClickEvent;


public class test {

 private List<Person> personList=new ArrayList<Person>();

 public List<Person> getPersonList() {
 return personList;
 }

 public void setPersonList(List<Person> personList) {
 this.personList = personList;
 }
 
 @AfterCompose
 public void afterCompose() {
 Person a=new Person();
 a.setAge(13);
 a.setBirthDate(new Date());
 a.setName("Burak");
 Person b=new Person();
 b.setAge(14);
 b.setBirthDate(new Date());
 b.setName("Veli");
 personList.add(a);
 personList.add(b);
 }
 
 @Command
 public void excel(@BindingParam("event") MouseEvent event) throws IOException
 {
 HSSFWorkbook workBook = new HSSFWorkbook();
 HSSFSheet workSheet = workBook.createSheet("Orders");
 Row excelRow = null;
 Cell excelCell = null;
 int rowNumber = 0;
 Component listbox=event.getTarget();
 while (!(listbox instanceof Listbox)) {
 listbox=listbox.getParent();
 }
 Listhead listHead = ((Listbox) listbox).getListhead();
 excelRow = workSheet.createRow(rowNumber++);
 for(int i=0;i<listHead.getChildren().size();i++)
 {
 Listheader listHeader = (Listheader) listHead.getChildren().get(i);
 
 excelCell = excelRow.createCell(i);
 excelCell.setCellValue(listHeader.getLabel());
 }
 for (int i=0; i < ((Listbox) listbox).getItems().size();i++) {
 Listitem item=((Listbox) listbox).getItems().get(i);
 excelRow = workSheet.createRow(rowNumber++);
 List<Listcell> cellList = item.getChildren();
 for(int k=0;k<cellList.size();k++) {
 excelCell = excelRow.createCell(k);
 excelCell.setCellValue(cellList.get(k).getLabel());
 }
 }
 List<Component> listBoxChildren = listbox.getChildren();
 File tempFile = new File("C:\\tempOrders.xls");
 FileOutputStream outputStream = new FileOutputStream(tempFile);
 workBook.write(outputStream);
 outputStream.close();
 Filedownload.save(tempFile, "application/file");
 }
 
}

<listbox model="@load(e.personList)" mold="paging" pageSize="1">
<auxhead>
 <auxheader><button label="Excel" sclass="pull-right" onClick="@command('excel', event=event)"></button></auxheader>
</auxhead>
<listhead>
 <listheader label="Ad"/>
 <listheader label="Yaş"/>
 <listheader label="Doğum"/>
</listhead>
<template name="model">
 <listitem>
 <listcell label="@load(each.name)"/>
 <listcell label="@load(each.age)"/>
 <listcell label="@load(each.birthDate)"/>
 </listitem>
</template>
</listbox>

Hello Again

After a while, hello again;

 

Some of you may know that, I quit my job and found another one.  I do not develop IBM Maximo anymore:) (That was a good tool though) I work for an investment company now. I started to develop IBM BPM, IBM B2B and some other tools. I will post as much as I can about these tools. But I may not answer all of the questions:(

 

For now, Have a great day:)