• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic Richfaces Tab Creation In Java Code ..How To Handle Create Event/Action

 
Ajay Kumar Noida
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Iam Creating Tab Dynamically in Java it working fine apart from only thing iam not able to manage that how to generate event and do some task on the Event OR
How can i Call A Action ..Below is My Code



public void generateComponentsForPdTabs(int projectId) {
vendorAssignedList = projectDao.getPdVendors(projectId);
vendorAssignedListForTab = new ArrayList();
tabsParent.getChildren().clear();
List<FormatTab> formatTabList2 = new ArrayList<FormatTab>();
formatTabList2 = formatTabDAO.getFormatTabsForFormat(projectId);
FacesContext context = FacesContext.getCurrentInstance();
Application application = context.getApplication();
tabsParent.setSwitchType("ajax");
if (formatTabList2 != null && formatTabList2.size() != 0) {
for (Iterator<FormatTab> it = formatTabList2.iterator(); it.hasNext();) {
FormatTab formatTabLocal = it.next();
HtmlTab tab = (HtmlTab) application.createComponent(HtmlTab.COMPONENT_TYPE);
tab.setLabel(formatTabLocal.getTabName());
tab.setName(formatTabLocal.getId());


if (formatTabLocal.isEnabled()) {
tab.setReRender("vendorTable");
tab.setStyle("font-weight:bold");
tab.getFocus();
}

//Parent Tabs have been generated
//creating a panel grid
tab.getChildren().clear();
HtmlPanelGrid htmlPanelGrid = (HtmlPanelGrid) application.createComponent(HtmlPanelGrid.COMPONENT_TYPE);
htmlPanelGrid.setColumns(1);
htmlPanelGrid.setWidth("100%");
//Toggle Panel for PD
HtmlSimpleTogglePanel simpleTogglePanel = (HtmlSimpleTogglePanel) application.createComponent(HtmlSimpleTogglePanel.COMPONENT_TYPE);
simpleTogglePanel.setReRender("revisionTable");
simpleTogglePanel.setSwitchType("ajax");
simpleTogglePanel.setLabel(formatTabLocal.getTabName() + " Details");
simpleTogglePanel.setOpened(false);
HtmlPanelGrid htmlPanelGrid2 = (HtmlPanelGrid) application.createComponent(HtmlPanelGrid.COMPONENT_TYPE);
htmlPanelGrid2.setId("revisionTable");
htmlPanelGrid2.setWidth("100%");
htmlPanelGrid2.setTitle("PD Details");
htmlPanelGrid2.setBorder(0);

setProjectDetailList(projectDetailDAO.getProjectProjectDetailList(projectId, formatTabLocal.getTabIndex()));
if (projectDetailList != null && projectDetailList.size() != 0) {
if (vendorAssignedList != null && vendorAssignedList.size() > 0) {
vendorAssignedListForTab = new ArrayList<Vendor>();
//lets try to set up vendor list here itself
for (Iterator<Vendor> it1 = vendorAssignedList.iterator(); it1.hasNext();) {
Vendor v = it1.next();
for (Iterator<ProjectDetail> it2 = projectDetailList.iterator(); it2.hasNext();) {
ProjectDetail projectDetail = it2.next();

if (v.getProjectDetail().getId().equals(projectDetail.getId())) {
vendorAssignedListForTab.add(v);
}
}
}
}
HtmlDataTable htmlDataTable = new HtmlDataTable();
htmlDataTable.setId("pdTable");
htmlDataTable.setWidth("100%");
htmlDataTable.setVar("fp");
htmlDataTable.setValue(projectDetailList);


/*******************************************************Column 1 ***************************************/
HtmlOutputText columnHeader = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
columnHeader.setValue("Revision");
UIColumn uiColumn1 = (UIColumn) application.createComponent(UIColumn.COMPONENT_TYPE);
uiColumn1.setHeader(columnHeader);
HtmlOutputText collobjects = new HtmlOutputText();
ValueBinding bindingCol = application.createValueBinding("#{fp.revision}");
collobjects.setValueBinding("value", bindingCol);
uiColumn1.getChildren().add(collobjects);

/*******************************************************Column 2 ***************************************/
HtmlOutputText columnHeader2 = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
columnHeader2.setValue("Description");
UIColumn uiColumn2 = (UIColumn) application.createComponent(UIColumn.COMPONENT_TYPE);
uiColumn2.setHeader(columnHeader2);
HtmlOutputText collobjects2 = new HtmlOutputText();
HtmlToolTip htt = new HtmlToolTip();
ValueBinding bindingColTT = application.createValueBinding("#{fp.description}");
htt.setValueBinding("value", bindingColTT);
ValueBinding bindingCol2 = application.createValueBinding("#{fp.shortDescription}");
collobjects2.setValueBinding("value", bindingCol2);
collobjects2.getChildren().add(htt);
uiColumn2.getChildren().add(collobjects2);

/*******************************************************Column 3 ***************************************/
HtmlOutputText columnHeader3 = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
columnHeader3.setValue("Request Date");
UIColumn uiColumn3 = (UIColumn) application.createComponent(UIColumn.COMPONENT_TYPE);
uiColumn3.setHeader(columnHeader3);
HtmlOutputText collobjects3 = new HtmlOutputText();
ValueBinding bindingCol3 = application.createValueBinding("#{fp.requestDate}");
collobjects3.setValueBinding("value", bindingCol3);
uiColumn3.getChildren().add(collobjects3);

/*******************************************************Column 4 ***************************************/
HtmlOutputText columnHeader4 = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
columnHeader4.setValue("Request Quantity");
UIColumn uiColumn4 = (UIColumn) application.createComponent(UIColumn.COMPONENT_TYPE);
uiColumn4.setHeader(columnHeader4);
HtmlOutputText collobjects4 = new HtmlOutputText();
ValueBinding bindingCol4 = application.createValueBinding("#{fp.requestQuantity}");
collobjects4.setValueBinding("value", bindingCol4);
uiColumn4.getChildren().add(collobjects4);


/*******************************************************Column 5 ***************************************/
HtmlOutputText columnHeader5 = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
columnHeader5.setValue("Request Due Date");
UIColumn uiColumn5 = (UIColumn) application.createComponent(UIColumn.COMPONENT_TYPE);
uiColumn5.setHeader(columnHeader5);
HtmlOutputText collobjects5 = new HtmlOutputText();
ValueBinding bindingCol5 = application.createValueBinding("#{fp.requestDueDate}");
collobjects5.setValueBinding("value", bindingCol5);
uiColumn5.getChildren().add(collobjects5);


/*******************************************************Column 6 ***************************************/
HtmlOutputText columnHeader6 = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
columnHeader6.setValue("Status");
UIColumn uiColumn6 = (UIColumn) application.createComponent(UIColumn.COMPONENT_TYPE);
uiColumn6.setHeader(columnHeader6);
HtmlOutputText collobjects6 = new HtmlOutputText();
ValueBinding bindingCol6 = application.createValueBinding("#{fp.pdStatus.name}");
collobjects6.setValueBinding("value", bindingCol6);
uiColumn6.getChildren().add(collobjects6);


/*******************************************************Column 7 ***************************************/
HtmlOutputText columnHeader7 = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
columnHeader7.setValue("Latest Attachments");
UIColumn uiColumn7 = (UIColumn) application.createComponent(UIColumn.COMPONENT_TYPE);
uiColumn7.setHeader(columnHeader7);
HtmlOutputText collobjects7 = new HtmlOutputText();
// ValueBinding bindingCol7 = application.createValueBinding("#{fp.requestDueDate}");
// collobjects7.setValueBinding("value", bindingCol7);
uiColumn7.getChildren().add(collobjects7);
htmlDataTable.getChildren().add(uiColumn1);
htmlDataTable.getChildren().add(uiColumn2);
htmlDataTable.getChildren().add(uiColumn3);
htmlDataTable.getChildren().add(uiColumn4);
htmlDataTable.getChildren().add(uiColumn5);
htmlDataTable.getChildren().add(uiColumn6);
htmlDataTable.getChildren().add(uiColumn7);

htmlPanelGrid2.getChildren().add(htmlDataTable);
} else {

HtmlOutputText outputText = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
outputText.setValue("No Revision in this project");
htmlPanelGrid2.getChildren().add(outputText);
}
HtmlOutputText hn = new HtmlOutputText();
hn.setValue("Abhishek is tryin gto get some thing rollong");
simpleTogglePanel.getChildren().add(hn);
htmlPanelGrid.getChildren().add(htmlPanelGrid2);
HtmlPanelGrid htmlPanelGridBottom = (HtmlPanelGrid) application.createComponent(HtmlPanelGrid.COMPONENT_TYPE);
htmlPanelGridBottom.setWidth("100%");
htmlPanelGridBottom.setColumns(2);
HtmlPanelGrid htmlPanelGrid3First = (HtmlPanelGrid) application.createComponent(HtmlPanelGrid.COMPONENT_TYPE);
htmlPanelGrid3First.setWidth("50%");
htmlPanelGrid3First.setBorder(0);
HtmlPanelGrid htmlPanelGrid3Second = (HtmlPanelGrid) application.createComponent(HtmlPanelGrid.COMPONENT_TYPE);
htmlPanelGrid3Second.setWidth("60%");
htmlPanelGrid3Second.setColumns(4);

//Add Revision Command Link

HtmlAjaxCommandLink link = (HtmlAjaxCommandLink) application.createComponent(HtmlAjaxCommandLink.COMPONENT_TYPE);
HtmlGraphicImage hg = new HtmlGraphicImage();
hg.setValue("images/AddRevision.gif");
hg.setStyle("border:0px");
link.setReRender("revisionData");
//link.setReRender("revisionDataTwo");
link.setActionExpression(application.getExpressionFactory().createMethodExpression(context.getELContext(), "#{projectDetailManageBean.goAddNewRevisionPage}", String.class, new Class<?>[0]));
link.setAjaxSingle(true);
link.setOncomplete("document.getElementById('wizardAddRevision').component.show()");
UIParameter id2 = (UIParameter) application.createComponent(UIParameter.COMPONENT_TYPE);
id2.setName("proId");
id2.setValue(projectId);
link.getChildren().add(hg);
link.getChildren().add(id2);
UIParameter id = (UIParameter) application.createComponent(UIParameter.COMPONENT_TYPE);
id.setName("tabIndex");
id.setValue(formatTabLocal.getTabIndex());
link.getChildren().add(id);

//Edit Revision Command Link

HtmlAjaxCommandLink link2 = (HtmlAjaxCommandLink) application.createComponent(HtmlAjaxCommandLink.COMPONENT_TYPE);
HtmlGraphicImage hg2 = new HtmlGraphicImage();
hg2.setValue("images/EditRevision.gif");
hg2.setStyle("border:0px");
link2.setReRender("revisionEditData");
link2.setReRender("revision");
link2.setActionExpression(application.getExpressionFactory().createMethodExpression(context.getELContext(), "#{projectDetailManageBean.editRevisionPage}", String.class, new Class<?>[0]));
link2.setAjaxSingle(true);
link2.setOncomplete("document.getElementById('wizardEditRevision').component.show()");
UIParameter id3 = (UIParameter) application.createComponent(UIParameter.COMPONENT_TYPE);
id3.setName("proId");
id3.setValue(projectId);
link2.getChildren().add(hg2);
link2.getChildren().add(id3);
UIParameter id1 = (UIParameter) application.createComponent(UIParameter.COMPONENT_TYPE);
id1.setName("tabIndex");
id1.setValue(formatTabLocal.getTabIndex());
link2.getChildren().add(id1);


//Send Vendor Request Command Link

HtmlAjaxCommandLink link3 = (HtmlAjaxCommandLink) application.createComponent(HtmlAjaxCommandLink.COMPONENT_TYPE);
HtmlGraphicImage hg3 = new HtmlGraphicImage();
hg3.setValue("images/SendVendorRequest.gif");
hg3.setStyle("border:0px");
link3.setReRender("vendorRevisionData");
link3.setReRender("createProjectTop");
link3.setReRender("vendorRevision");
link3.setActionExpression(application.getExpressionFactory().createMethodExpression(context.getELContext(), "#{editProjectManagedBean.showVendorAssignmentForm}", String.class, new Class<?>[0]));
link3.setAjaxSingle(true);
link3.setOncomplete("document.getElementById('wizardVendorAssignment').component.show()");
UIParameter id4 = (UIParameter) application.createComponent(UIParameter.COMPONENT_TYPE);
id4.setName("proId");
id4.setValue(projectId);
link3.getChildren().add(hg3);
link3.getChildren().add(id4);


UIParameter id5 = (UIParameter) application.createComponent(UIParameter.COMPONENT_TYPE);
id5.setName("tabIndex");
id5.setValue(formatTabLocal.getTabIndex());
link3.getChildren().add(id5);

//Send Request To Approver

HtmlAjaxCommandLink link4 = (HtmlAjaxCommandLink) application.createComponent(HtmlAjaxCommandLink.COMPONENT_TYPE);
HtmlGraphicImage hg4 = new HtmlGraphicImage();
hg4.setValue("images/SendtoApprover.gif");
hg4.setStyle("border:0px");
link4.setReRender("revisionApprovalData");
link4.setReRender("createProjectTop");
link4.setReRender("approverRevision");
link4.setActionExpression(application.getExpressionFactory().createMethodExpression(context.getELContext(), "#{editProjectManagedBean.showApproverAssignmentForm}", String.class, new Class<?>[0]));
link4.setAjaxSingle(true);
link4.setOncomplete("document.getElementById('wizardApproverAssignment').component.show()");
UIParameter id6 = (UIParameter) application.createComponent(UIParameter.COMPONENT_TYPE);
id6.setName("proId");
id6.setValue(projectId);
link4.getChildren().add(hg4);
link4.getChildren().add(id6);


UIParameter id7 = (UIParameter) application.createComponent(UIParameter.COMPONENT_TYPE);
id7.setName("tabIndex");
id7.setValue(formatTabLocal.getTabIndex());
link4.getChildren().add(id7);




htmlPanelGrid3Second.getChildren().add(link);
if (projectDetailList != null && projectDetailList.size() != 0) {
htmlPanelGrid3Second.getChildren().add(link2);
htmlPanelGrid3Second.getChildren().add(link3);
htmlPanelGrid3Second.getChildren().add(link4);
}
htmlPanelGrid.getChildren().add(htmlPanelGridBottom);
htmlPanelGridBottom.getChildren().add(htmlPanelGrid3First);
htmlPanelGridBottom.getChildren().add(htmlPanelGrid3Second);


/**************************************************************************************************************************************************/
//List OF Vendors

HtmlPanelGrid htmlPanelForVendor = new HtmlPanelGrid();
htmlPanelForVendor.setColumns(1);
HtmlOutputText hOutputText = new HtmlOutputText();
hOutputText.setValue("List Of Vendors");
hOutputText.setStyleClass("txt_normal_bold");
htmlPanelForVendor.getChildren().add(hOutputText);

if (vendorAssignedListForTab.size() == 0) {
HtmlOutputText vendorMessage = new HtmlOutputText();
vendorMessage.setValue("No Vendor Assigned Yet");
vendorMessage.setStyleClass("txt_normal_bold");
htmlPanelForVendor.getChildren().add(vendorMessage);
} else {
HtmlDataTable htmlDataTableForVendor = new HtmlDataTable();
htmlDataTableForVendor.setId("vendorTable");
htmlDataTableForVendor.setWidth("100%");
htmlDataTableForVendor.setVar("val");
htmlDataTableForVendor.setValue(vendorAssignedListForTab);


/*******************************************************Column 1 ***************************************/
HtmlOutputText columnHeader = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
columnHeader.setValue("Name");
UIColumn uiColumn1 = (UIColumn) application.createComponent(UIColumn.COMPONENT_TYPE);
uiColumn1.setHeader(columnHeader);
HtmlOutputText collobjects = new HtmlOutputText();
ValueBinding bindingCol = application.createValueBinding("#{val.vendor.firstName}");
collobjects.setValueBinding("value", bindingCol);
uiColumn1.getChildren().add(collobjects);

/*******************************************************Column 2 ***************************************/
HtmlOutputText columnHeader2 = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
columnHeader2.setValue("PD #");
UIColumn uiColumn2 = (UIColumn) application.createComponent(UIColumn.COMPONENT_TYPE);
uiColumn2.setHeader(columnHeader2);
HtmlOutputText collobjects2 = new HtmlOutputText();
ValueBinding bindingCol2 = application.createValueBinding("#{val.projectDetail.pdNumber}");
collobjects2.setValueBinding("value", bindingCol2);
uiColumn2.getChildren().add(collobjects2);

/*******************************************************Column 3 ***************************************/
HtmlOutputText columnHeader3 = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
columnHeader3.setValue("Revision #");
UIColumn uiColumn3 = (UIColumn) application.createComponent(UIColumn.COMPONENT_TYPE);
uiColumn3.setHeader(columnHeader3);
HtmlOutputText collobjects3 = new HtmlOutputText();
ValueBinding bindingCol3 = application.createValueBinding("#{val.projectDetail.revision}");
collobjects3.setValueBinding("value", bindingCol3);
uiColumn3.getChildren().add(collobjects3);

/*******************************************************Column 4 ***************************************/
HtmlOutputText columnHeader4 = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
columnHeader4.setValue("PD Requested On");
UIColumn uiColumn4 = (UIColumn) application.createComponent(UIColumn.COMPONENT_TYPE);
uiColumn4.setHeader(columnHeader4);
HtmlOutputText collobjects4 = new HtmlOutputText();
ValueBinding bindingCol4 = application.createValueBinding("#{val.projectDetail.requestDate}");
collobjects4.setValueBinding("value", bindingCol4);
uiColumn4.getChildren().add(collobjects4);

/*******************************************************Column 5 ***************************************/
HtmlOutputText columnHeader5 = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
columnHeader5.setValue("PD Submitted");
UIColumn uiColumn5 = (UIColumn) application.createComponent(UIColumn.COMPONENT_TYPE);
uiColumn5.setHeader(columnHeader5);
HtmlOutputText collobjects5 = new HtmlOutputText();
ValueBinding bindingCol5 = application.createValueBinding("#{val.projectDetail.createdBy}");
collobjects5.setValueBinding("value", bindingCol5);
uiColumn5.getChildren().add(collobjects5);


/*******************************************************Column 6 ***************************************/
HtmlOutputText columnHeader6 = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
columnHeader6.setValue("PD Approved By");
UIColumn uiColumn6 = (UIColumn) application.createComponent(UIColumn.COMPONENT_TYPE);
uiColumn6.setHeader(columnHeader6);
HtmlOutputText collobjects6 = new HtmlOutputText();
ValueBinding bindingCol6 = application.createValueBinding("#{val.dummyApprovedBy.firstName} #{val.dummyApprovedBy.lastName}");
collobjects6.setValueBinding("value", bindingCol6);
uiColumn6.getChildren().add(collobjects6);

/*******************************************************Column 7 ***************************************/
HtmlOutputText columnHeader7 = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
columnHeader7.setValue("Quote Requested");
UIColumn uiColumn7 = (UIColumn) application.createComponent(UIColumn.COMPONENT_TYPE);
uiColumn7.setHeader(columnHeader7);
HtmlOutputText collobjects7 = new HtmlOutputText();
ValueBinding bindingCol7 = application.createValueBinding("#{val.quotationRquestDate}");
collobjects7.setValueBinding("value", bindingCol7);
uiColumn7.getChildren().add(collobjects7);


/*******************************************************Column 8 ***************************************/
HtmlOutputText columnHeader8 = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
columnHeader8.setValue("Quote Submitted");
UIColumn uiColumn8 = (UIColumn) application.createComponent(UIColumn.COMPONENT_TYPE);
uiColumn8.setHeader(columnHeader8);
HtmlOutputText collobjects8 = new HtmlOutputText();
ValueBinding bindingCol8 = application.createValueBinding("#{val.quoteApprovedDate}");
collobjects8.setValueBinding("value", bindingCol8);
uiColumn8.getChildren().add(collobjects8);


/*******************************************************Column 9 ***************************************/
HtmlOutputText columnHeader9 = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
columnHeader9.setValue("Quote Approved By");
UIColumn uiColumn9 = (UIColumn) application.createComponent(UIColumn.COMPONENT_TYPE);
uiColumn9.setHeader(columnHeader9);
HtmlOutputText collobjects9 = new HtmlOutputText();
ValueBinding bindingCol9 = application.createValueBinding("#{val.quoteApprovedDate}");
collobjects9.setValueBinding("value", bindingCol9);
uiColumn9.getChildren().add(collobjects9);


htmlDataTableForVendor.getChildren().add(uiColumn1);
htmlDataTableForVendor.getChildren().add(uiColumn2);
htmlDataTableForVendor.getChildren().add(uiColumn3);
htmlDataTableForVendor.getChildren().add(uiColumn4);
htmlDataTableForVendor.getChildren().add(uiColumn5);
htmlDataTableForVendor.getChildren().add(uiColumn6);
htmlDataTableForVendor.getChildren().add(uiColumn7);
htmlDataTableForVendor.getChildren().add(uiColumn8);
htmlDataTableForVendor.getChildren().add(uiColumn9);
htmlPanelForVendor.getChildren().add(htmlDataTableForVendor);
}

 
Ajay Kumar Noida
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can Any One Help me ..I Just wanted to Call a Action or Create a Event
Below is My Code to Generate Tabs

public void generateComponentsForPdTabs(int projectId) {
vendorAssignedList = projectDao.getPdVendors(projectId);
vendorAssignedListForTab = new ArrayList();
tabsParent.getChildren().clear();
List<FormatTab> formatTabList2 = new ArrayList<FormatTab>();
formatTabList2 = formatTabDAO.getFormatTabsForFormat(projectId);
FacesContext context = FacesContext.getCurrentInstance();
Application application = context.getApplication();
tabsParent.setSwitchType("ajax");
if (formatTabList2 != null && formatTabList2.size() != 0) {
for (Iterator<FormatTab> it = formatTabList2.iterator(); it.hasNext();) {
FormatTab formatTabLocal = it.next();
HtmlTab tab = (HtmlTab) application.createComponent(HtmlTab.COMPONENT_TYPE);
tab.setLabel(formatTabLocal.getTabName());
tab.setName(formatTabLocal.getId());

if (formatTabLocal.isEnabled()) {
tab.setReRender("vendorTable");
tab.setStyle("font-weight:bold");
tab.getFocus();
}



PLease Any One Help me out
 
Micky Kr
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!