Hi,
speaking in code, it would be something like this:
public void deleteRow(ActionEvent actionEvent)
{
UIData uiData = JsfUtils.getUIDataParent(actionEvent);
getList().remove(uiData.getRowIndex());
}
In JsfUtils:
public static UIData getUIDataParent(ActionEvent e)
{
UIComponent component = e.getComponent();
while (component != null && !(component instanceof UIData))
{
component = component.getParent();
}
return (UIData) component;
}
cheers,
Gerald
On 11/10/06, Damar Thapa <[EMAIL PROTECTED]> wrote:
Hi,
Sorry to bother you all again!
What is the command in action event method to get the dataTable's data
so as to manipulate it?
I will start googling for this tonight.
Thanks,
Damar
On 11/9/06, Damar Thapa <[EMAIL PROTECTED]> wrote:
> Thanks, Simon.
>
> I will try this.
>
> Damar
>
>
> On 11/9/06, Simon Kitching <[EMAIL PROTECTED]> wrote:
> > Hi Damar,
> >
> > I think one way to do this is write a simple class:
> > public class SelectableApplicant {
> > private boolean isSelected;
> > private Applicant applicant;
> > // add getters/setters for above
> > }
> >
> > Change applicationProcess.applicants to return a list of
> > SelectableApplicant rather than Applicant directly.
> >
> > Your JSP columns can be:
> > <h:column>
> > <t:selectBooleanCheckbox .. value="#{application.selected}"/>
> > </h:column>
> >
> > <h:column>
> > <h:outputText value="#{application.applicant.firstName}"/>
> > </h:column>
> >
> > etc.
> >
> > Obviously, you can now iterate over the rows in the data model, checking
> > the boolean flag and if set processing the associated applicant object.
> >
> > Regards,
> >
> > Simon
> >
> > Damar Thapa wrote:
> > > Hi,
> > >
> > > Thanks for your help – truly appreciated.
> > >
> > > Now, I am in the last stage of this problem, ie I have to save the
> > > data from the dataTable into a new file and in new Class structure. It
> > > may be straight forward, anyway, I explain what I am trying to do.
> > > The following is the snapshot of my dataTable:
> > >
> > > <t:dataTable id="applicantsData"
> > > ……
> > > ……
> > > var="application"
> > > value="#{applicationProcess.applications}"
> > > border="1"
> > > preserveDataModel="false">
> > > <h:column>
> > > <f:facet name="header"><h:outputText value="Selected"/></f:facet>
> > > <t:selectBooleanCheckbox forceId="true" id="chk"
> > > onclick="onChangeSelect(this);"
> > > value="#{applicationProcess.selected}"/>
> > > </h:column>
> > >
> > > <h:column>
> > > <f:facet name="header"><h:outputText value="First Name"/></f:facet>
> > > <h:outputText value="#{application.firstName}"/>
> > > </h:column>
> > >
> > > Surname,
> > > Class
> > > ….
> > >
> > >
> > > </t:dataTable>
> > >
> > > The dataTable is using applicationProcess.applications list, which is
> > > a list of Applicant object. Applicant Object has firstName, surname,
> > > class, etc. and I have added <t:selectBooleanCheckBox> to determine if
> > > the individual applicants are selected (and its value ie
> > > applicationProcess.selected is not the property of Applicant Class).
> > >
> > > What I have to do is iterate on the rows of dataTable and if the
> > > <selectBooleanCheckbox> is checked, put it in another List. How can I
> > > do this?
> > >
> > > In the following,say:
> > >
> > > public void saveData(ActionEvent event){
> > >
> > > FacesContect context=FacesContext.getCurrentInstance();
> > > List aList=event.getComponent()…..
> > > …..
> > >
> > > In the above, does event returns List from the dataTable? The value
> > > of <selectBooleanCheckbox> ie applicationProcess.selected is not the
> > > property of <Applicant> class, is it going to be the problem>
> > >
> > >
> > > Any pointers would be highly appreciated, and sorry for lengthy and
> > > too novice questions.
> > >
> > > With regards,
> > >
> > > Damar
> > >
> >
> >
>
>
> --
> With regards,
>
> Damar Thapa
>
--
With regards,
Damar Thapa
--
http://www.irian.at
Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German
Professional Support for Apache MyFaces