Re: What will be the Pattern for the Following url?

Splash Forums PrettyFaces Users What will be the Pattern for the Following url? Re: What will be the Pattern for the Following url?

#19850

Subodh
Participant

package com.kuber.web.jsfbeans;

import java.io.Serializable;

import java.util.ArrayList;

import java.util.List;

import java.util.Map;

import java.util.TreeMap;

import javax.faces.component.html.HtmlInputHidden;

import javax.faces.component.html.HtmlOutputLink;

import javax.faces.component.html.HtmlOutputText;

import javax.faces.component.html.HtmlPanelGroup;

import javax.faces.context.FacesContext;

import org.apache.log4j.Logger;

import org.richfaces.component.html.HtmlDataTable;

import com.kuber.web.cache.FeatureDBManager;

import com.kuber.web.db.WbFeatureDetails;

import com.kuber.web.db.WbFeatureInfo;

import com.kuber.web.model.WbFeatureInfoExtend;

import com.kuber.web.utils.JSFControlUtils;

;

public class FeatureBean implements Serializable{

Logger logger = Logger.getLogger(FeatureBean.class);

private HtmlPanelGroup dynamicDataTableGroup;

private HtmlPanelGroup tabpanel;

private HtmlInputHidden hiddenField;

private List _interesting_numbers_list = null;

private String featureName = null;

private boolean _renderedTab = false;

public boolean is_renderedTab() {

return _renderedTab;

}

public void set_renderedTab(boolean tab) {

_renderedTab = tab;

}

public String getFeatureName() {

return featureName;

}

public void setFeatureName(String featureName) {

this.featureName = featureName;

}

public HtmlInputHidden getHiddenField() {

return hiddenField;

}

public void setHiddenField(HtmlInputHidden hiddenField) {

this.hiddenField = hiddenField;

}

public String getFeaturePriority() {

String priority = ((String) hiddenField.getAttributes().get(“dir”)).trim();

return priority;

}

/**

* Returns the actual data to be shown corresponding to a feature

*

* @param query

* @return

*/

public List getFeatureData(String featureName) {

return FeatureDBManager.getInstance().getFeatureData(featureName);

}

/**

* Returns the Feature Information based on feature priority or feature name

*

* @param priority

* @param featureName

* @return

*/

private WbFeatureInfoExtend getFeatureInfo(String priority, String featureName) {

if (priority != null && priority.length() > 0) {

return FeatureDBManager.getInstance().getFeatureInfoPriorityMap().get(new Integer(priority));

} else {

return FeatureDBManager.getInstance().getFeatureInfoNameMap(featureName);

}

}

/**

* Returns the column details for a particular feature

*

* @param featureName

* @return

*/

private List<WbFeatureDetails> getFeatureTableDetails(String featureName) {

return FeatureDBManager.getInstance().getFeatureColumnDetailMap().get(featureName);

}

/**

* Generates HTMLPanelGroup control based on the FeatureInfo Object passed

* to it

*

* @param feautureInfo

* @return

*/

private HtmlPanelGroup generatePanelGroup(WbFeatureInfoExtend featureInfo, boolean sort) {

String featureName = featureInfo.getWbfiName();

String featureDesc = featureInfo.getWbfiDesc();

List featureData = FeatureDBManager.getInstance().getFeatureData(featureName);

List columnDetails = getFeatureTableDetails(featureName);

HtmlDataTable table = JSFControlUtils.generateDataTable(columnDetails, featureData, sort);

return JSFControlUtils.generatePanelGroup(featureInfo, table);

}

/**

* New Method to generate the Intresting Number Broader way

*/

private HtmlPanelGroup generateRichTab(WbFeatureInfoExtend featureInfo, boolean sort) {

String featureName = featureInfo.getWbfiName();

String featureDesc = featureInfo.getWbfiDesc();

List featureData = FeatureDBManager.getInstance().getFeatureData(featureName);

List columnDetails = getFeatureTableDetails(featureName);

boolean featuredetails = sort;

if (featuredetails == true && featureData != null) {

TreeMap groupByData = new TreeMap();

List temp_list = new ArrayList();

for (int i = 0; i < featureData.size(); i++) {

Object temp_obj[] = (Object[]) featureData.get(i);

String temp_key = (String) temp_obj[1];

if (groupByData.containsKey(temp_key)) {

temp_list = (List) groupByData.get(temp_key);

temp_list.add(temp_obj);

} else {

temp_list = new ArrayList();

temp_list.add(temp_obj);

groupByData.put(temp_key, temp_list);

}

}

return JSFControlUtils.generateRichTab(columnDetails, groupByData, sort, featureInfo);

}

return null;

}

public void setPanelGroupBasedOnFeaturePriority(HtmlPanelGroup panelGroup) {

dynamicDataTableGroup = panelGroup;

}

/**

* Generates the HTMLPanelGroup for a feature based on priority

*

* @return

*/

public HtmlPanelGroup getPanelGroupBasedOnFeaturePriority() {

String priority = getFeaturePriority();

WbFeatureInfo featureInfo = getFeatureInfo(priority, null);

dynamicDataTableGroup = generatePanelGroup((WbFeatureInfoExtend) featureInfo, false);

HtmlOutputLink cl = new HtmlOutputLink();

cl.setValue(featureInfo.getWbfiUrl());

cl.setStyleClass(“moreLink”);

cl.setTitle(“more”);

HtmlOutputText more = new HtmlOutputText();

cl.setStyleClass(“moreLink”);

more.setValue(“more…”);

cl.getChildren().add(more);

dynamicDataTableGroup.getChildren().add(cl);

return dynamicDataTableGroup;

}

/**

*

*/

public void setPanelGroupBasedOnFeatureName(HtmlPanelGroup panelGroup) {

dynamicDataTableGroup = panelGroup;

}

/**

* Generates HTMLPanelGroup based on Feature Name

*

* @return

*/

public void setTabBasedOnFeatureName(HtmlPanelGroup tabPanel) {

tabpanel = tabPanel;

}

public HtmlPanelGroup getTabBasedOnFeatureName() {

if (!showTab()) {

tabpanel = new HtmlPanelGroup();

tabpanel.setRendered(false);

return tabpanel;

}

WbFeatureInfoExtend featureInfo = getFeatureInfo(null, featureName);

tabpanel = generateRichTab(featureInfo, true);

return tabpanel;

}

public HtmlPanelGroup getPanelGroupBasedOnFeatureName() {

if (showTab()) {

dynamicDataTableGroup = new HtmlPanelGroup();

dynamicDataTableGroup.setRendered(false);

return dynamicDataTableGroup;

}

WbFeatureInfoExtend featureInfo = getFeatureInfo(null, featureName);

dynamicDataTableGroup = generatePanelGroup(featureInfo, true);

return dynamicDataTableGroup;

}

private boolean showTab() {

WbFeatureInfoExtend featureInfo = getFeatureInfo(null, featureName);

if (featureInfo.getWbfiGroupBy() != null && featureInfo.getWbfiGroupBy() > 0) {

_renderedTab = true;

} else {

_renderedTab = false;

}

return _renderedTab;

}

public void setDynamicDataTableGroup(HtmlPanelGroup dynamicDataTableGroup) {

this.dynamicDataTableGroup = dynamicDataTableGroup;

}

public List get_interesting_numbers_list() {

return FeatureDBManager.getInstance().getIntrestingNumberList();

}

public void set_interesting_numbers_list(List _interesting_numbers_list) {

this._interesting_numbers_list = _interesting_numbers_list;

}

public HtmlPanelGroup getTabpanel() {

return tabpanel;

}

public void setTabpanel(HtmlPanelGroup tabpanel) {

this.tabpanel = tabpanel;

}

}