Hi,
I have the following table:
<body> <f:view> <h:form id="assetOverviewForm"> <h:outputText value="#{gui['assets.overview']}" styleClass="heading2"/> <ig:gridView dataSource="#{assetOverviewController.allAssets}" pageSize="10"> <f:facet name="header"> <h:outputText value="#{gui['assets.listHeading']}" /> </f:facet> <ig:column sortBy="publicId"> <f:facet name="header"> <h:outputText value="#{gui['asset.id']}" /> </f:facet> <h:outputText value="#{DATA_ROW.publicId}" /> </ig:column> <ig:column> <h:commandLink action="#{assetDetailController.showAssetDetail}"> <h:graphicImage value="images/buttonDetail.gif" style="border: 0px" /> <f:param name="id" value="#{DATA_ROW.id}"/> </h:commandLink> <h:commandButton image="images/icon_remove.gif" action="#{assetOverviewController.deleteAsset}" value="#{gui['delete']}" onclick="if (!confirm('#{gui['asset.removeConfQuestion']}')) return false; else setIdForRemoving('#{DATA_ROW.id}');"> </h:commandButton> </ig:column> </ig:gridView> <h:inputHidden id="assetRemoveId" value="-1"></h:inputHidden> <h:commandLink action="#{assetController.showAssetAdding}"> <h:outputText value="#{gui['asset.addNew']}" /> </h:commandLink> </h:form> </f:view></body>
Functionality should be as follows: each row contains two commands for detail and for deletion. Confirmation dialog must be opened before deletion-operation.
When there is only button for deletion then everything works fine - user clicks, confirmation dialog is opened. But when I add commandLink then it doesn't work - no confirmation dialog is opened and form is submitted. Also table sorting doesn't work with two commands.
I found out that this is because JS error - "curForm is undefined". It seems that JSF engine createdwrong page ?!?
Please I would very appreciate any help.
Thank you in advance,
ANECT
I tried to make a simple application implementing the functionality you described. The source code is posted bellow. Everything seemed to work fine, all events were fired, confirmation dialog appers and sorting is also OK. Although it did not matter in my example you can try to divide the link and the button in two separate columns. Please, take a look at my example bellow and if there is is still any issue that disburbs you, don't bother to ask.
In JSF:
<f:view>
<h:form id="assetOverviewForm">
<h:outputText value="Message" binding="#{twoCommands.msg}"></h:outputText>
<ig:gridView dataSource="#{twoCommands.empList}" pageSize="10"
binding="#{twoCommands.grid}">
<f:facet name="header">
<h:outputText value="Employee List"></h:outputText>
</f:facet>
<ig:column sortBy="firstName">
<h:outputText value="First Name"></h:outputText>
<h:outputText value="#{DATA_ROW.firstName}"></h:outputText>
</ig:column>
<ig:column>
<h:commandLink value="Detail" action="#{twoCommands.showDetails}">
<f:param name="fname" value="#{DATA_ROW.firstName}"></f:param>
</h:commandLink>
<h:commandButton value="Delete"
onclick="if(!confirm('Are you sure you want to remove #{DATA_ROW.firstName} from the list?')) return false"></h:commandButton>
</ig:gridView>
</f:view>
</body>
In JAVA:
private List empList = RequiredInputsBean.createList();
FacesContext facesContext = FacesContext.getCurrentInstance();
String str = (String) facesContext.getExternalContext().getRequestParameterMap().get("fname");
System.out.println("First Name: " + str);
}
RowItem rowItem = (RowItem) e.getComponent().getParent().getParent();
Person person = (Person) HtmlGridView.getDataRow(rowItem);
Iterator it = empList.iterator();
Person pers = (Person) it.next();
empList.remove(pers);
...
// Getters and Setters
Regards!
Thank you for your reply.
I have solved problem with JS (problem with displaying confirmation dialog) by replacing Sun JSF RI by Apache MyFaces.
But sorting still doesn't work when there are more then one command (doesn't matter if one or more ig:columns are used).
Anect
Hello,
I found out finally the problem!
I had this
<h:commandLink action="#{assetController.showAssetEditation}" value="#{gui['edit']}"> <f:param name="id" value="#{DATA_ROW.id}"/> </h:commandLink> Now I have:
<h:commandLink action="#{assetController.showAssetEditation}" value="#{gui['edit']}"> <f:param name="asset_id" value="#{DATA_ROW.id}"/> </h:commandLink>
There is one difference only - content of f:param's attribute name.
I haven't found anywhere that attribute name could't have "id".
PETER
If you suppose there is a problem with the distributed source, I cannot help you further. You could submit a new supprot request on our web site.
I looked at your sent sample and the problem still lasts...
I found out that the problem is with Javascript. When I have two commands in one row and then I want to sort or go to next page then the following JS error occured in fileigf_core (version Version 8.1.20081.2010):
formId.indexOf is not a functionreturn(!ig.isNull(this.httpRequestImpl))...);compNs=compNs.substring(0,formIdidx);}
I use libraries from my last instalation - 8.1.20081.2005 - NetAdvantage for JSF 2008 Volume 1 from 16. June.
When I have tried your sent sample via email then it worked properly. So I copied resource directory and all jar files to my project (only I have JSF MyFaces implementation) and the problem still lasts - same JSF error.
I'm not sure that the problem is in the two commands since I made and example with two commands and working sorting. I suppose you should probably check for problems in another part of the source comming with the new command.