0

I'm a beginner in Oracle ADF Faces, before that. I have known Primefaces, I usually use @process and @update in commandLink and commandButton to process or update specify the place. ADF faces have made me confused cause when I created a commandLink (or link) it's will be processed all components inside the form

Here's an illustration Img Look at the picture. When I click " button ", it will process all form, but I just want to process " table " only and update "child_form_02". How can I do it in ADF Faces?

Thank in advance.

Tea
  • 873
  • 2
  • 7
  • 25
  • 1
    Possible duplicate of [Understanding PrimeFaces process/update and JSF f:ajax execute/render attributes](http://stackoverflow.com/questions/25339056/understanding-primefaces-process-update-and-jsf-fajax-execute-render-attributes) – Jasper de Vries Apr 14 '17 at 10:04
  • I'm not sure about it. Does Oracle support it by another way, not use f:ajax? Like the way Primefaces did – Tea Apr 14 '17 at 10:18
  • `f:ajax` is general JSF and can be used with any component framework – Jasper de Vries Apr 14 '17 at 10:19
  • I see, I will try it – Tea Apr 14 '17 at 10:21
  • I don't think use f:ajax is a way, 'cause my button inside so many components, about 15 components, I don't want to write too many id inside f:ajax ? – Tea Apr 14 '17 at 10:50

2 Answers2

0

You can split your form into 2 subforms (af:subform) Please see an example below: http://www.oracle.com/technetwork/developer-tools/adf/learnmore/40-ppr-subform-169182.pdf

Florin Marcus
  • 1,657
  • 1
  • 12
  • 11
  • So, It didn't work. I'm using JOPO classes, maybe it's reason I can't take the step " SKIP VALIDATION" and it still don't working :( – Tea Apr 14 '17 at 10:45
  • Using ADF without business components makes no sense, if you ask me. ADF Rich Faces with ADF BC is the development stack heavily tested by Oracle. All other proposed ‘solutions’ are just marketing. – Florin Marcus Apr 14 '17 at 11:07
  • Thank you. But sometimes you cannot choose the way that makes to project when you are an employee and hired by the company. – Tea Apr 15 '17 at 05:21
0

As explained in the answer on Understanding PrimeFaces process/update and JSF f:ajax execute/render attributes, you should use:

<h:commandButton ...>
  <f:ajax execute="childForm2:clientId1 childForm2:clientId2 ..."/>
</h:commandButton>

As you already mentioned, this might result in a painfully long and unmaintainable string. In PrimeFaces you could use @(...) to jQuery the inputs you want to process. In plain JSF there is no such thing.

What you could do is create a method in a utility bean which gets you all input clientIds within a specific component. The OmniFaces Components utility class comes in handy here:

public String inputClientIds(String clientId)
{
  UIComponent component = Components.findComponent(clientId);
  List<String> clientIds = new ArrayList<>();
  for (UIInput input : Components.findComponentsInChildren(component, UIInput.class)) {
    clientIds.add(input.getClientId());
  }
  return String.join(" ", clientIds);
}

Now you can use it in your XHTML like:

<h:commandButton ...>
  <f:ajax execute="#{ajaxBean.inputClientIds('childForm2')}"/>
</h:commandButton>

If you are looking for a pure JSF / non-OmniFaces solution, things will get a bit more verbose:

public String inputClientIds(String clientId)
{
  UIComponent component = FacesContext.getCurrentInstance().getViewRoot().findComponent(clientId);
  List<String> clientIds = new ArrayList<>();
  for (UIInput input : findChildsOfType(component, UIInput.class)) {
    clientIds.add(input.getClientId());
  }
  return String.join(" ", clientIds);
}


public static <C extends UIComponent> List<C>
findChildsOfType(UIComponent component,
                 Class<C> type)
{
  List<C> result = new ArrayList<>();
  findChildsOfType(component, type, result);
  return result;
}


private static <C extends UIComponent> void
findChildsOfType(UIComponent component,
                 Class<C> type,
                 List<C> result)
{
  for (UIComponent child : component.getChildren()) {
    if (type.isInstance(child)) {
      result.add(type.cast(child));
    }
    findChildsOfType(child, type, result);
  }
}

You might consider creating a class with some utility methods.

Community
  • 1
  • 1
Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
  • Oh, thank you. I will try it. But I don't think Omifaces can integrate with Oracle ADF. I had tried use with and it's not working – Tea Apr 15 '17 at 05:39
  • If you are having issues with OmniFaces, please report them at https://github.com/omnifaces/omnifaces/issues – Jasper de Vries Apr 15 '17 at 07:01
  • By the way, OmniFaces should work with ADF. I'm only using the Components utility class here. You could also resolve the components using the plain JSF API. The idea will still be the same. – Jasper de Vries Apr 18 '17 at 12:43
  • I'll try tomorrow. But you know, ADF faces really make me confused :/ – Tea Apr 18 '17 at 16:01
  • I have put a request for BalusC on github to ask him " Does Omifaces support ADF Faces". Thank for your supporting :) – Tea Apr 20 '17 at 08:16
  • OmniFaces should work just fine in combination with any component library. There might be issues with specific parts like for example a resource handler. The `Components` class simply does plain JSF stuff. I cannot imagine it to give you issues when you are using ADF. [See for yourself](https://github.com/omnifaces/omnifaces/blob/develop/src/main/java/org/omnifaces/util/Components.java#L341). – Jasper de Vries Apr 20 '17 at 08:32
  • Omifaces doesn't support my ADF version. So bad:/ – Tea May 08 '18 at 12:13