问题
in my case i have 3 columns, every column is dependent on previous one. user must enter all cells in column 1 so column 2 be editable then he enters column 2 to make column 3 editable. if he cleared cell then dependent columns should be disabled.
how could i handle it using JavaScript
please find below image :
回答1:
I am assuming your table cell will be a af:input text
.
You don't need explicitly JS to achieve this as you can achieve it in ADF itself. So if you dont have requirement to do it in JS then you can try this below way. With Button we are having action
or actionListener
, same way we have valueChangeListener
with inputText
.
Suppose you are having 2 input text (2 cells in table).
<af:inputText value="#{bindings.ESal.inputValue}"
label="#{bindings.ESal.hints.label}"
required="#{bindings.ESal.hints.mandatory}"
columns="#{bindings.ESal.hints.displayWidth}"
maximumLength="#{bindings.ESal.hints.precision}"
shortDesc="#{bindings.ESal.hints.tooltip}" id="it11"
autoSubmit="true" valueChangeListener="#{bean1.textChange}"
>
<f:validator binding="#{bindings.ESal.validator}" />
</af:inputText>
- Here make
autoSubmit = true
for the input text which will be changed. Use valueChangeListener event and create a method as
textChange
as shown above. It will be triggered whenever there is a change in your input text (on tab change also it will be triggered).<af:inputText label="Output label" id="ol1" partialTriggers="it11" binding="#{bean1.lbl}" disabled="true"/>
This inputText is dependent on first one. It's disabled by default.
- Use PartialTrigger and assign first inputText in it.
Create a binding for this inputText which can be used in managed bean.
public void textChange(ValueChangeEvent valueChangeEvent) { // Add event code here... if(!(valueChangeEvent.getNewValue()==null || valueChangeEvent.getNewValue().equals(""))) // checking input Text value { // if not null lbl.setDisabled(false); //then enable it AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance(); adfFacesContext.addPartialTarget(lbl); // refresh the binding } else { lbl.setDisabled(true); //else disable it. AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance(); adfFacesContext.addPartialTarget(lbl); }
}
回答2:
Enable the java RowImpl for your ViewObject So you can control the returned data in the getters
来源:https://stackoverflow.com/questions/53100030/check-if-table-column-has-empty-cell