Create attachqueue programatically RF4.2.3Final
chan32167 Apr 11, 2013 1:20 PMHello,
I would like to know how to attach an attachqueue component to an inputtext programatically, what i have tried so far has not worked, i have the following code(please ignore some of the logic):
private HtmlInputText getInputTextNumber() {
HtmlInputText inputText = new HtmlInputText();
inputText.setId(identificador);
inputText.addValueChangeListener(getValueChangeListener());
inputText.addClientBehavior("change", getReRenderBehavior());
BigDecimal valorDefecto = BigDecimal.ZERO;
if (atributo.getAtributo().getFormula() != null) {
inputText.setReadonly(Boolean.TRUE);
valorDefecto = calcularValorFormula(atributo.getAtributo()
.getFormula(), valoresBean);
} else if (valoresBean.get(identificador) != null) {
valorDefecto = valoresBean.get(identificador).getValor()
.getNumberValue();
} else if (valorBDD != null) {
valorDefecto = new BigDecimal(valorBDD);
} else if (atributo.getValorDefecto() != null
&& !atributo.getValorDefecto().isEmpty()) {
valorDefecto = new BigDecimal(atributo.getValorDefecto());
} else {
valorDefecto = BigDecimal.ZERO;
}
inputText.setValueExpression(
"value",
getValor(valoresBean, new CampoNumberWrapper(valorDefecto),
getRequiredMessage()));
inputText.setDisabled(readOnly);
inputText.setConverter(new NumberLocaleConverter());
inputText.setOnkeypress("return aceptarNumerosDecimales(event, this);");
inputText.setOnfocus("setId('" + identificador + "');");
return inputText;
}
private AjaxBehavior getReRenderBehavior() {
AjaxBehavior ajaxBehavior = (AjaxBehavior) FacesContext
.getCurrentInstance().getApplication()
.createBehavior(AjaxBehavior.BEHAVIOR_ID);
Collection<String> execute = new ArrayList<String>();
Collection<String> reRender = new ArrayList<String>();
execute.add("@this");
Iterator<Entry<String, AtributoDinamicoWrp>> it = valoresBean
.entrySet().iterator();
while (it.hasNext()) {
Entry<String, AtributoDinamicoWrp> e = it.next();
execute.add(e.getKey());
if (e.getValue().getAtributoPantalla().getAtributo().getFormula() != null
|| e.getValue().getAtributoPantalla().getAtributo()
.getFuncionObtiene() != null) {
reRender.add(e.getKey());
}
}
ajaxBehavior.setExecute(execute);
ajaxBehavior.setRender(reRender);
return ajaxBehavior;
}
And i created the the attachqueue like this:
private UIAttachQueue createUIAttachQueue() {
UIAttachQueue uiAttachQueue = new UIAttachQueue();
uiAttachQueue.setName("myQueue");
uiAttachQueue.setRequestGroupingId("mygroupingId");
return uiAttachQueue;
}
what i have tried so far to make it work:
in
private HtmlInputText getInputTextNumber() {
...
// code from above
UIAttachQueue uiAttachQueue = createUIAttachQueue();
inputText.getChildren().add(uiAttachQueue);
uiAttachQueue.associateWith(inputText);
uiAttachQueue.setParent(inputText);
}
also tried
private AjaxBehavior getReRenderBehavior() {
...
// code from above
UIAttachQueue uiAttachQueue = createUIAttachQueue();
uiAttachQueue.associateWith(ajaxBehavior);
}
both dont work, the queue exists on the xhtml
the closest i could get but didnt use an attachqueue was just to set the queueId on the ajaxbehavior, but i really need to use a requestGroupingId
i need the requestgroupid because what we do is, we generate a form with inputtexts where users insert numbers, use tab to move to the next inputtext. On the event onchange we calculate some values for other inputtexts, the problem is that only the last request should be processed to avoid innecesary calculations with data that has already changed(the calculations take some time)