How to get value from MAF form layout(read-only form) from amx page?

335 Views Asked by At

I have read-only form. I want to delete form related to task id, if user press Yes button . But i am not able to capture value of taskid to send it to my java class. How can i achieve this? I m trying to do this but not able to delete because i am not getting value from the form layout.

I want to know how to send value of taskid(value="#{bindings.taskId.inputValue}") through yes button having actionListener="#{closeTask.click}" to my java class.

Here is my amx page.

<?xml version="1.0" encoding="UTF-8" ?>

<amx:view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:amx="http://xmlns.oracle.com/adf/mf/amx"

          xmlns:dvtm="http://xmlns.oracle.com/adf/mf/amx/dvt">

  <amx:panelPage id="pp1" >

    <amx:facet name="header">

      <amx:outputText value="Task Details" id="ot1"/>

    </amx:facet>

    <amx:facet name="primary">

      <amx:commandButton id="cb1" action="__back"/>

    </amx:facet>

    <amx:facet name="secondary">

      <amx:commandButton id="cb2"/>

    </amx:facet>

    <amx:validationGroup id="group2">

      <amx:panelFormLayout id="pfl1">

        <amx:panelLabelAndMessage label="#{bindings.taskId.hints.label}" id="plam2">

          <amx:outputText value="#{bindings.taskId.inputValue}" id="ot3"

                          rendered="#{bindings.taskId}"/>

        </amx:panelLabelAndMessage>

        <amx:panelLabelAndMessage label="#{bindings.taskType.hints.label}" id="plam1">

          <amx:outputText value="#{bindings.taskType.inputValue}" id="ot2"/>

        </amx:panelLabelAndMessage>

        <amx:panelLabelAndMessage label="#{bindings.taskName.hints.label}" id="plam3">

          <amx:outputText value="#{bindings.taskName.inputValue}" id="ot5"/>

        </amx:panelLabelAndMessage>

      </amx:panelFormLayout>

    </amx:validationGroup>







    <amx:commandButton text="DELETE" id="cb3"   inlineStyle="left:150px;"  >

    <amx:validationBehavior id="validationBehavior2" group="group2"/>



     <amx:showPopupBehavior popupId="popup1"

                                align="topStart" alignId="pp1" type="action" decoration="anchor" id="spb1"/>



                                 </amx:commandButton>

  </amx:panelPage>

   <amx:popup id="popup1"



              animation="slideUp"

              backgroundDimming="on"

              autoDismiss="true">

    <amx:commandButton text="No" id="cb4" action="__back"/>

    <amx:outputText value="Are you sure?" id="ot4"/>

   <amx:commandButton text="Yes" id="cb5"  actionListener="#{closeTask.click}" />          FROM HERE I AM GETTING THE ISSUE.

    </amx:popup>

</amx:view>
1

There are 1 best solutions below

0
Magnus On

there are few ways to access bindings value in java class. First try inside closeTask.click method:

        ValueExpression ve =
        AdfmfJavaUtilities.getValueExpression("#{bindings.taskId.inputValue}", String.class);
    String taskId = (String) ve.getValue(AdfmfJavaUtilities.getELContext());

Alternatively you could add propertylistener to pass temp variable in your button:

<amx:commandButton text="Yes" id="cb5">
   <amx:setPropertyListener from="#{bindings.taskId.inputValue}" 
     to="#{viewScope.YourBean.valueHolder}" type="action" id="spl5"/>
            </amx:commandButton> 

And call closeTask.click when vauleHolder is changed: in YourBean.java:

private String valueHolder; //declare var

  public void setValueHolder(String valueHolder) {
  this.valueHolder = valueHolder;
  closeTask.click(valueHolder) // call your method here with passed taskid
}

I hope it helps.