1
votes

I have created jsf form at backing bean. I have created form, it is being shown on screen with values successfully. When I click sumbit button, backing bean method is invoked with ActionEvent but updated input values are not submitted to backend. Backign bean entity object values are not updated.

Is there any wrong? Thanks so much for your helps,

Br. Ramazan

HtmlForm form = new HtmlForm();
form.setId(appletWrapper.getName()+"_FORM");

PanelGrid panelGrid = (PanelGrid)createComponent(PanelGrid.COMPONENT_TYPE);
form.getChildren().add(panelGrid);
panelGrid.setColumns(4);
panelGrid.setId(appletWrapper.getName()+"_FORM_PANEL");

for (FieldWrapper fieldWrapper : appletWrapper.getFields()) {
    panelGrid.getChildren().add(new UIFieldLabel(fieldWrapper).component(entities));
    panelGrid.getChildren().add(newFieldComponent(fieldWrapper, entities));
}

HtmlPanelGroup panelGroup = new HtmlPanelGroup();
panelGroup.setId(appletWrapper.getName()+"_PANEL_GROUP");
panelGrid.getFacets().put("footer", panelGroup);

CommandButton commandButton = new CommandButton();
panelGroup.getChildren().add(commandButton);
commandButton.setId(appletWrapper.getName()+"_UPDATE");
commandButton.setAjax(true);
commandButton.setValue("update");
commandButton.setProcess("@this");
commandButton.setType("submit");
MethodExpression updateEntityME = createMethodExpression("#{mainBean.entityUpdateListener}", null, new Class[] {ActionEvent.class });
commandButton.addActionListener(new MethodExpressionActionListener(updateEntityME));

return form;

Edited: I gave all components a fixed id.

One of my coponents genarated like that;

InputText inputText = (InputText)createComponent(InputText.COMPONENT_TYPE);
inputText.setId(fieldAlphanumericWrapper.getName());
inputText.setValueExpression("value", createValueExpression("#{mainBean.selection."+fieldAlphanumericWrapper.getProperty()+"}", Object.class));
return inputText;

My backing bean target method;

public void entityUpdateListener(ActionEvent actionEvent) {
    TAccount tAccount = (TAccount)getSelection();
    System.out.println("tAccount.gettWebsite():"+tAccount.gettWebsite());
}

The main problem is that actually; When I press commandButton mainBean.setSelection is not invoked, so backing bean object is not updated. I cant take updated object instance through actionEvent instance.

1
Give all forms, inputs and buttons a fixed ID instead of letting JSF autogenerate it.BalusC
Thanks BalusC for your suggestion, I gave fixed ids but still in same situation.Sertan Ramazan Pekin

1 Answers

1
votes

I found solution, cause of problem was this line;

commandButton.setProcess("@this");

I have changed to this and problem solved.

commandButton.setProcess("@form");

Br. Ramazan