0
votes

I have a popup inside that popup
I have a form <h:form id="vpmoForm"> inside this I have a datatable <p:dataTable id="reqTypeDtbl"> and inside that datatable I have an <h:inputText id="except" > which I am rendering based on a conditon. Here the <h:inputText id="except" > should get rendered based on aother component <h:selectOneMenu> ajax event in another column in same datatable

I got the condition in the backing bean but how do I update the <h:inputText id="except" > to render it in the datatable.

Code that I using is given below

<p:dataTable id="reqTypeDtbl" scrollable="true" scrollHeight="150"
value="#{Bean.ReqDetailslsList}"
rowIndexVar="index" var="eachrow">
    <h:selectOneMenu id="tssreq" value="#{vpmoReqDtlRow.tssReqId}"
rendered="#{Bean.vpmoEditFlag == true}">
<f:selectItems value="#{Bean.vpmoTSSList}"
var="tss" itemLabel="#{tss.label}" itemValue="#{tss.value}" />
<p:ajax  listener="#{Bean.getTssId}"  
execute="@this" partialSubmit="true" />
<f:param name="rowidno" value="#{index}" required="true" />
</h:selectOneMenu>
  <h:inputText value="#{eachrow.exceptionNum}" id="except" style="width:100%"  rendered="#{Bean.EditFlag == true and eachrow.tssReqId eq 'Y'}" />
</p:dataTable >


As I stated above ,I want to render the <h:inputText> based on the another component <h:selectOneMenu> when its ajax event is called and I want to enable the <h:inputText> from the backing bean.
Here is the code that I am using for the Ajax method

public void getTssId(AjaxBehaviorEvent evt) {
Map<String, String> params = FacesContext.getCurrentInstance()
                .getExternalContext().getRequestParameterMap();
            int index = Integer.parseInt(params.get("rowidno"));
                String selected = vpmoReqDetailslsList.get(index).getTssReqId();
        if (selected.equalsIgnoreCase("y")) {
            vpmoReqDetailslsList.get(index).setTssReqId("Y");
            RequestContext requestContext = RequestContext.getCurrentInstance();
            requestContext.update(":vpmoForm:reqTypeDtbl:except"); //.....I AM TRYING TO UPDATE THE UI FROM HERE 
        }


I am trying to find a way to update the `<h:inputText id="except" >` component from the backing bean so that it can render in the UI.<br/> 
Any suggestions will be really helpful to resolve this issue.
1
use rendered property of h:inputText.Makky
I dont see a coloumn tag in dataTable Pls give the correct code to resolve your problem.BholaVishwakarma
I just updated my question with the proper code.techy360
update the hole Datatable it will be easy else see showcase.omnifaces.org/utils/AjaxBholaVishwakarma
There is button that we are providing for adding a row,so if the user clicks that button , a new row will get added and in that row for the specific index I need to enable the inputtext based on the selection menu.I got the selected values of the selectonemenu as I stated above in the ajax code in the backing bean but based on that selected value i need to enable the inputtext.I am using primefaces not omni faces.Please have look at the Ajax code given above.techy360

1 Answers

0
votes

If the component is not rendered you won't be able to update it (as far as my knowledge goes).

See if you can place it inside a container:

<p:outputPanel id="txt">
    <p:inputText value="#{bean.value}" rendered="#{bean.condition}" />
</p:outputPanel>

<p:commandButton update="txt" value="Send" />

If you have access to the rowIndex from you managedbean you can do a more specific update

<p:outputPanel styleClass="updateMe#{index}">
    <p:inputText value="#{item.name}" rendered="#{bean.condition}" />
</p:outputPanel>

Update it from your managedbean:

RequestContext.getCurrentInstance().update("@(.updateMe" + index + ")");