aspose file tools*
The moose likes JSF and the fly likes setting action in commnad link not working in a dynamic dataTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "setting action in commnad link not working in a dynamic dataTable" Watch "setting action in commnad link not working in a dynamic dataTable" New topic
Author

setting action in commnad link not working in a dynamic dataTable

hei cham chan
Greenhorn

Joined: Mar 23, 2008
Posts: 2
outerDataTable.setRows(getSessionBean1().getDataList().getDocArrayList().size());

outerDataTable.setValueExpression("value", createValueExpression("#{ShowResult.temp}", List.class));
outerDataTable.setVar("dataItem");


///////////////////////////
//construct inner dataTable
///////////////////////////
UIColumn dtCol = new UIColumn();

HtmlDataTable innerDataTable = new HtmlDataTable();
innerDataTable.setValueExpression("value", createValueExpression("#{dataItem}", List.class));
innerDataTable.setVar("innerDataItem");

UIColumn rowCol = new UIColumn();
UIColumn idCol = new UIColumn();
UIColumn testCol = new UIColumn();

HtmlOutputText colHeader = new HtmlOutputText();
colHeader.setValue("ID");
idCol.setHeader(colHeader);

colHeader = new HtmlOutputText();
colHeader.setValue("relevancy");
testCol.setHeader(colHeader);


// the action event of xpathLink is not fired here...
HtmlCommandLink xpathLink = new HtmlCommandLink();
HtmlOutputText idName = new HtmlOutputText();

idName.setValueExpression("value", createValueExpression("#{innerDataItem}" , String.class));
xpathLink.setActionExpression(createMethodExpression("#{ShowResult.testing}", void.class, new Class[0]));
xpathLink.setId("testing1");
xpathLink.setImmediate( true );
xpathLink.setStyle("font-size: 12px");
xpathLink.getChildren().add(idName);

idCol.getChildren().add(xpathLink);
innerDataTable.getChildren().add(idCol);
innerDataTable.getChildren().add(testCol);
/////////////////////////////////////////////////////////
//// construct link to view source
/////////////////////////////////////////////////////////
HtmlOutputLink fileLink = new HtmlOutputLink();
HtmlOutputText fileName = new HtmlOutputText();
fileLink.setValueExpression("value", createValueExpression("http://localhost:" + Page1.getPORT() + "/data/" +
"#{SessionBean1.dataList.docArrayList[ShowResult.outerDataTable.rowIndex]}" + ".xml", String.class));
fileName.setValueExpression("value", createValueExpression("View source: #{SessionBean1.dataList.docArrayList[ShowResult.outerDataTable.rowIndex]}" + ".xml", String.class));
fileName.setStyle("text-align: center");
fileLink.getChildren().add(fileName);
innerDataTable.setHeader(fileLink);
//dtCol.getChildren().add(fileLink);
dtCol.getChildren().add(innerDataTable);

outerDataTable.getChildren().add(dtCol);



I am dynamically constructing a dataTable.
The main problem is the command link xpathLink, which cannot enter the testing method, ShowResult is a page bean.
Can someone help me out?

This is method testing().
public void testing() {
JOptionPane.showMessageDialog(null, "in function testing");
String in ="success";
//return in;
}
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1844

Did you make the bean scope as "session"?


Krishna Srinivasan
Spring Tutorials, OCAJP Mock Questions, 400+ OCPJP Mock Questions
hei cham chan
Greenhorn

Joined: Mar 23, 2008
Posts: 2
Yes, i changed the ShowResult into session scope. But when i click on the link. It still can't work. just the data on the table remains.
 
 
subject: setting action in commnad link not working in a dynamic dataTable