ice:dataTable problem
[Logo]
Forums for ICEfaces and ICEpdf
[Search] Search   [Recent Topics] Recent Topics   [Groups] Home Page | www.icefaces.org  [Register] Register  [Login] Login 
ice:dataTable problem  XML
Forum Index -> General Help
Author Message
lomniczi

Joined: 20/10/2009 00:00:00
Messages: 9
Offline


Hi,

I'm using ICEfaces 1.8.2 on Glassfish 2.1. I downloaded the sample application from this site ('cause I'm a beginner in ICEfaces):

http://facestutorials.icefaces.org/tutorial/dynamic-includes-tutorial.html

This sample: http://facestutorials.icefaces.org/tutorial/dynamic-includes-tutorial.zip

Then I started to modify the sample. I modified the logic of tree building and I put a ice:dataTable component to the content-facelet.jspx but base navigation logic wasn't modified: if you click on a node of tree, PageContentBean.contentVisibleAction() will be called, and the backing bean for content-facelet.jspx will use the navigation bean. dataTable contains columns those contains input elements like inputText, etc. Each error messages are placed after each input elements like this:

<h:column>
<f:facet name="header">
<ice:outputText value="#{msg.product_prop_table_frnum}"/>
</f:facet>
<ice:inputText id="frnum" value="#{ownProps.frnum}" required="false"/>
<ice:message for="frnum" style="color: red"></ice:message>
</h:column>

ice:dataTable is placed in a form. There is a button above the form, it have an action listener. Action listener saves data to the database, it works fine. If I don't fill a required field, relevant error message will be shown, it's ok too. But after that I cannot make "dissappear" this message. It means that I click on different nodes of tree, table is shown properly, but the first field (that was empty and had a message) is empty and error message is still shown. I saw on the log that no more validation after clicking (because button wasn't pushed), but as I mentioned table is shown properly, the appropriate method of backing bean is called. I tried that I added "immediate" attribute to ice:commandLink of nodes of tree, but the result is the same.

Could you help me anyone? Might the problem is that navigation logic of the original sample cannot be used to this purpose?
Knuckle

Joined: 22/11/2008 00:00:00
Messages: 75
Offline


Hi ya Lom

You could try binding the inputText componet to your backing bean.
When, "I click on different nodes of tree" -> Fire an Event -> Call the inputText componets resetValue() method.

Cheers
Wayne

lomniczi

Joined: 20/10/2009 00:00:00
Messages: 9
Offline


Hi Wayne,

Thx your quick answer.
I've tried your suggestion. I bound the ice:dataTable to a HtmlDataTable component in a backing bean (I couldn't bind the inputText because rows and input inside are shown in a dynamically way from database). In the contentVisibleAction action listener I get the HtmlDataTable component this way:

HtmlDataTable ownDataTable = ( HtmlDataTable ) facesContext.getApplication().createValueBinding( "#{productmanager.ownDataTable}" ).getValue( facesContext );

After I reset all input values with this code:

private void resetInputValues( UIComponent component )
{
if ( component != null )
{
List<UIComponent> children = component.getChildren();
for ( UIComponent child : children )
{
if ( child instanceof UIInput )
{
UIInput input = ( UIInput ) child;
input.resetValue();
logger.finest( "### " + input.getId() + ": reset value" );
}
resetInputValues( child );
}
}
}

...

resetInputValues( ownDataTable );

Unfortunately, I get the same error.

Did I understand you well?
lomniczi

Joined: 20/10/2009 00:00:00
Messages: 9
Offline


Hi Wayne,

I added an new input text to my form OUTSIDE the dataTable. I bound it to an HtmlInputText property of my bean (with "binding" attribute). I reset the field in action listener. It worked fine! I think the problem is that inputs there are INSIDE the dataTable. I can't find the solution:(

Best regards,

Rudi
Knuckle

Joined: 22/11/2008 00:00:00
Messages: 75
Offline


Hi Rudi

I would try binding the inputText in a similar way as you explained in your last post. If the inputText componet is to be dymanically rendered, you can use the "rendered" attribute.

Cheers
Wayne
lomniczi

Joined: 20/10/2009 00:00:00
Messages: 9
Offline


Hi Wayne,

I think I found the reason of the problem: HtmlDataTable component saves all its children and restore them, but I cannot "see" children, because I just access child components. E.g. if table contains ten rows including ten HtmlInputText, I can access just one HtmlInputText. Here is the tree that I can see:

(see tree.txt)

If table contains ten rows tree will look like the same above. If I call resetValue() on the one HtmlInputText, DataTable will it overwritten then it restores the children state. The related code:

(see jspx.txt)

To your suggestion: As you can see, in value of dname field refers to the dataTable cycle variable: ownProps. Do you have an idea howto bind dName to a backing bean if dName is in the dataTable "cycle"?

Best regards,

Rudi
 Filename jspx.txt [Disk] Download
 Description code
 Filesize 1 Kbytes
 Downloaded:  21 time(s)

 Filename tree.txt [Disk] Download
 Description from log
 Filesize 3 Kbytes
 Downloaded:  14 time(s)

Knuckle

Joined: 22/11/2008 00:00:00
Messages: 75
Offline


Hi Rudi

A cople of points.

1. There is probably no need to bind the dataTable.

2. I would do something like:
Code:
 <ice:inputText id="dname" value="#{ownProps.DName}" binding="#{productmanager.myInputText}" required="true"/>
 


3. I would also stick to naming conventions. ie value="#{ownProps.dName}"

Cheers
Wayne
lomniczi

Joined: 20/10/2009 00:00:00
Messages: 9
Offline


Hi Wayne,

Thx, I see your last suggestion. Sry for my incompetence but I need bind input text MULTIPLE components 'cause it is contained in the datatable, input text has multiple values. E.g. I could bind it to a HtmlInputText[] attribute, but I should know which iteration is the current one, and no numeric loop variable available. If I do what you wrote productmanager.myInputText will refer JUST one input field and I cannot access its other values.

Best regards,

Rudi
Knuckle

Joined: 22/11/2008 00:00:00
Messages: 75
Offline


Hi Rudi

I am assuming you want all occurances of your InputText componets to reset on the event of an included page being re-displayed, you can call the resetValue method on the componet before it is dispalyed which will return it to the default state.

You do not require a numeric loop variable for the object in the List, just use a unique property of the object.

Cheers
Wayne
lomniczi

Joined: 20/10/2009 00:00:00
Messages: 9
Offline


Hi Wayne,

I put edit functionality out of dataTable. There is a form that will be filled current row data if you push the Edit button on the row. This solution it works fine. Nevertheless, I'm interested in your suggestion.

" you can call the resetValue method on the componet before it is dispalyed which will return it to the default state."

Could you write me exactly to where should I put resetValue() call? Is it a lifecycle related thing and should I put it in a specific lifecycle method?

Best regards,

Rudi
Knuckle

Joined: 22/11/2008 00:00:00
Messages: 75
Offline


Hi Rudi

Glad to hear you found a solution.

I would call your backing bean like this :

"if you click on a node of tree, PageContentBean.contentVisibleAction() will be called"

Code:
 public void contentVisibleAction() {
     FacesContext context = FacesContext.getCurrentInstance();
     MyBean myBean = (MyBean) context.getELContext().getELResolver().getValue(context.getELContext(), null, "myBean");
 
     myBean.getMyInputText().resetValue();
 }
 


Cheers
Wayne
 
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team