You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Stephan Hesmer <sh...@apache.org> on 2004/12/04 18:54:05 UTC

Bug with dataTable ?

Hi,

I have a JSF application that uses a dataTable to display name/value 
pairs. As an object model I use an ArrayList that contains a bean.
Right next to each entry I want to have one "delete" commandLink that 
contains the "name" of my bean as an attribute so that I can delete it 
in the defined actionListener.
The problem I have is that the actionListener is not called at all for 
some reason. I also get this error while the page is being rendered.

Dec 4, 2004 12:46:45 PM net.sourceforge.myfaces.el.VariableResolverImpl 
resolveVariable
SEVERE: Variable 'prefEntry' could not be resolved.

Here is the JSP that is being rendered:
<f:view>
     <h:form>
         <B><h:outputText value='#{myText.available_bookmarks}'/></B><br>
         <h:dataTable value="#{preferences.convertedPreferences}"
                      var="prefEntry">
             <h:column>
                 <f:facet name="header">
                     <h:outputText value='#{myText.name}'/>
                 </f:facet>
                 <h:outputText value='#{prefEntry.name}'/>
             </h:column>
             <h:column>
                 <f:facet name="header">
                     <h:outputText value='#{myText.url}'/>
                 </f:facet>
                 <h:outputText value='#{prefEntry.value}'/>
             </h:column>
             <h:column>
                 <h:commandLink action="delete"
                                actionListener="#{bookmark.delete}">
                     <h:outputText value="#{myText.delete}" />
                     <f:attribute name="name" value="#{prefEntry.name}"/>
                 </h:commandLink>
             </h:column>
         </h:dataTable>
     </h:form>
</f:view>


And here is the java source of the bean (BTW, I don't define this entry 
bean in the faces-config - I tried, but it didn't make any difference):

public class PreferenceEntryBean
{
	private String name;
	private String value;
	
	/**
	 * @return Returns the name.
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name The name to set.
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return Returns the value.
	 */
	public String getValue() {
		return value;
	}
	/**
	 * @param value The value to set.
	 */
	public void setValue(String value) {
		this.value = value;
	}
}

Thanks for your help
Stephan

Re: Bug with dataTable ?

Posted by Heath Borders <he...@gmail.com>.
Sorry, I don't know what to tell you.  If you can, try running it
through the debugger.


On Sun, 05 Dec 2004 01:49:52 -0500, Stephan Hesmer <sh...@apache.org> wrote:
> yes,
> 
> the bean is the one I posted in my last mail (see below)
> 
> this is the faces-config
> <faces-config>
>      <managed-bean>
>          <managed-bean-name>bookmark</managed-bean-name>
>          <managed-bean-class>
>              com.mycompany.BookmarkBean
>          </managed-bean-class>
>          <managed-bean-scope>request</managed-bean-scope>
>      </managed-bean>
>      <managed-bean>
>          <managed-bean-name>preferences</managed-bean-name>
>          <managed-bean-class>
>              com.mycompany.PreferencesBean
>          </managed-bean-class>
>          <managed-bean-scope>request</managed-bean-scope>
>      </managed-bean>
> </faces-config>
> 
> Thanks for the help
> Stephan
> 
> 
> 
> Heath Borders wrote:
> > Ok, further assumptions:
> > You should have a managed bean called "bookmark" and it should have a
> > method with the following signature: "public void delete(ActionEvent
> > event)"
> >
> > Is that the case?
> >
> >
> > On Sat, 04 Dec 2004 17:18:41 -0500, Stephan Hesmer <sh...@apache.org> wrote:
> >
> >>Heath,
> >>
> >>thanks for answering. Yes, all you wrote is correct. I have that bean, I
> >>have that in my configuration.
> >>After I read your mail I simply delete the line
> >><f:attribute name="name" value="#{prefEntry.name}" />
> >>an retried my app.
> >>
> >>The problem still persists - The ActionListener is not called.
> >>
> >>here is my bookmark bean, which is also defined in the faces-config.
> >>
> >>public class BookmarkBean implements java.io.Serializable
> >>{
> >>        private String name;
> >>        private String URL;
> >>
> >>        public String getName() {
> >>                return name;
> >>        }
> >>        public void setName(String name) {
> >>                this.name = name;
> >>        }
> >>        public String getURL() {
> >>                return URL;
> >>        }
> >>        public void setURL(String url) {
> >>                URL = url;
> >>        }
> >>
> >>        public void delete(ActionEvent event) throws
> >>AbortProcessingException {
> >>                String name = (String)event.getComponent().getAttributes().get("name");
> >>
> >>                System.out.println("deleting name: "+name);
> >>        }
> >>
> >>}
> >>
> >>Thanks
> >>Stephan
> >>
> >>
> >>
> >>Heath Borders wrote:
> >>
> >>>Here is what you should have:
> >>>
> >>>A faces-config managed bean named "preferences".
> >>>
> >>>Inside that bean, you need a read property for "convertedPreferences"
> >>>(probably a method called "getConvertedPreferences()" that returns
> >>>either an Array or a List.
> >>>
> >>>That Array or List should contain a PreferenceEntryBean which has the
> >>>getName/SetName, getValue/setValue methods.
> >>>
> >>>Most likely, your problem is with the following line of code:
> >>>
> >>>"<f:attribute name="name" value="#{prefEntry.name}" />
> >>>
> >>>What this line does is add the value of #{prefEntry.name}" to the
> >>>attribute Map of the parent commandLink under the key "name".  Most
> >>>likely, this will not get you anything, judging from your JSP.
> >>>
> >>>My guess is that you want a way for your ActionListener method to know
> >>>which row the user selected.  Fortunately, UIData's (which
> >>>HtmlDataTable extends), provides this facility.  When a UIComponent
> >>>contained within a UIData generates an event, the UIData must put the
> >>>request-scope variable of the row of that UIComponent on the request
> >>>scope.  This means that you can retrieve the prefEntry bean from the
> >>>row the user clicked by retrieving the bean from request scope.
> >>>
> >>>
> >>>
> >>>On Sat, 04 Dec 2004 12:54:05 -0500, Stephan Hesmer <sh...@apache.org> wrote:
> >>>
> >>>
> >>>>Hi,
> >>>>
> >>>>I have a JSF application that uses a dataTable to display name/value
> >>>>pairs. As an object model I use an ArrayList that contains a bean.
> >>>>Right next to each entry I want to have one "delete" commandLink that
> >>>>contains the "name" of my bean as an attribute so that I can delete it
> >>>>in the defined actionListener.
> >>>>The problem I have is that the actionListener is not called at all for
> >>>>some reason. I also get this error while the page is being rendered.
> >>>>
> >>>>Dec 4, 2004 12:46:45 PM net.sourceforge.myfaces.el.VariableResolverImpl
> >>>>resolveVariable
> >>>>SEVERE: Variable 'prefEntry' could not be resolved.
> >>>>
> >>>>Here is the JSP that is being rendered:
> >>>><f:view>
> >>>>    <h:form>
> >>>>        <B><h:outputText value='#{myText.available_bookmarks}'/></B><br>
> >>>>        <h:dataTable value="#{preferences.convertedPreferences}"
> >>>>                     var="prefEntry">
> >>>>            <h:column>
> >>>>                <f:facet name="header">
> >>>>                    <h:outputText value='#{myText.name}'/>
> >>>>                </f:facet>
> >>>>                <h:outputText value='#{prefEntry.name}'/>
> >>>>            </h:column>
> >>>>            <h:column>
> >>>>                <f:facet name="header">
> >>>>                    <h:outputText value='#{myText.url}'/>
> >>>>                </f:facet>
> >>>>                <h:outputText value='#{prefEntry.value}'/>
> >>>>            </h:column>
> >>>>            <h:column>
> >>>>                <h:commandLink action="delete"
> >>>>                               actionListener="#{bookmark.delete}">
> >>>>                    <h:outputText value="#{myText.delete}" />
> >>>>                    <f:attribute name="name" value="#{prefEntry.name}"/>
> >>>>                </h:commandLink>
> >>>>            </h:column>
> >>>>        </h:dataTable>
> >>>>    </h:form>
> >>>></f:view>
> >>>>
> >>>>And here is the java source of the bean (BTW, I don't define this entry
> >>>>bean in the faces-config - I tried, but it didn't make any difference):
> >>>>
> >>>>public class PreferenceEntryBean
> >>>>{
> >>>>       private String name;
> >>>>       private String value;
> >>>>
> >>>>       /**
> >>>>        * @return Returns the name.
> >>>>        */
> >>>>       public String getName() {
> >>>>               return name;
> >>>>       }
> >>>>       /**
> >>>>        * @param name The name to set.
> >>>>        */
> >>>>       public void setName(String name) {
> >>>>               this.name = name;
> >>>>       }
> >>>>       /**
> >>>>        * @return Returns the value.
> >>>>        */
> >>>>       public String getValue() {
> >>>>               return value;
> >>>>       }
> >>>>       /**
> >>>>        * @param value The value to set.
> >>>>        */
> >>>>       public void setValue(String value) {
> >>>>               this.value = value;
> >>>>       }
> >>>>}
> >>>>
> >>>>Thanks for your help
> >>>>Stephan
> >>>>
> >>>
> >>>
> >>>
> >>
> >
> >
> 
> 


-- 
If you don't have a GMail account, I probably have 5 invites.  Just ask!
-Heath Borders-Wing
hborders@mail.win.org

Re: Bug with dataTable ?

Posted by Stephan Hesmer <sh...@apache.org>.
yes,

the bean is the one I posted in my last mail (see below)

this is the faces-config
<faces-config>
     <managed-bean>
         <managed-bean-name>bookmark</managed-bean-name>
         <managed-bean-class>
             com.mycompany.BookmarkBean
         </managed-bean-class>
         <managed-bean-scope>request</managed-bean-scope>
     </managed-bean>
     <managed-bean>
         <managed-bean-name>preferences</managed-bean-name>
         <managed-bean-class>
             com.mycompany.PreferencesBean
         </managed-bean-class>
         <managed-bean-scope>request</managed-bean-scope>
     </managed-bean>
</faces-config>


Thanks for the help
Stephan

Heath Borders wrote:
> Ok, further assumptions:
> You should have a managed bean called "bookmark" and it should have a
> method with the following signature: "public void delete(ActionEvent
> event)"
> 
> Is that the case?
> 
> 
> On Sat, 04 Dec 2004 17:18:41 -0500, Stephan Hesmer <sh...@apache.org> wrote:
> 
>>Heath,
>>
>>thanks for answering. Yes, all you wrote is correct. I have that bean, I
>>have that in my configuration.
>>After I read your mail I simply delete the line
>><f:attribute name="name" value="#{prefEntry.name}" />
>>an retried my app.
>>
>>The problem still persists - The ActionListener is not called.
>>
>>here is my bookmark bean, which is also defined in the faces-config.
>>
>>public class BookmarkBean implements java.io.Serializable
>>{
>>        private String name;
>>        private String URL;
>>
>>        public String getName() {
>>                return name;
>>        }
>>        public void setName(String name) {
>>                this.name = name;
>>        }
>>        public String getURL() {
>>                return URL;
>>        }
>>        public void setURL(String url) {
>>                URL = url;
>>        }
>>
>>        public void delete(ActionEvent event) throws
>>AbortProcessingException {
>>                String name = (String)event.getComponent().getAttributes().get("name");
>>
>>                System.out.println("deleting name: "+name);
>>        }
>>
>>}
>>
>>Thanks
>>Stephan
>>
>>
>>
>>Heath Borders wrote:
>>
>>>Here is what you should have:
>>>
>>>A faces-config managed bean named "preferences".
>>>
>>>Inside that bean, you need a read property for "convertedPreferences"
>>>(probably a method called "getConvertedPreferences()" that returns
>>>either an Array or a List.
>>>
>>>That Array or List should contain a PreferenceEntryBean which has the
>>>getName/SetName, getValue/setValue methods.
>>>
>>>Most likely, your problem is with the following line of code:
>>>
>>>"<f:attribute name="name" value="#{prefEntry.name}" />
>>>
>>>What this line does is add the value of #{prefEntry.name}" to the
>>>attribute Map of the parent commandLink under the key "name".  Most
>>>likely, this will not get you anything, judging from your JSP.
>>>
>>>My guess is that you want a way for your ActionListener method to know
>>>which row the user selected.  Fortunately, UIData's (which
>>>HtmlDataTable extends), provides this facility.  When a UIComponent
>>>contained within a UIData generates an event, the UIData must put the
>>>request-scope variable of the row of that UIComponent on the request
>>>scope.  This means that you can retrieve the prefEntry bean from the
>>>row the user clicked by retrieving the bean from request scope.
>>>
>>>
>>>
>>>On Sat, 04 Dec 2004 12:54:05 -0500, Stephan Hesmer <sh...@apache.org> wrote:
>>>
>>>
>>>>Hi,
>>>>
>>>>I have a JSF application that uses a dataTable to display name/value
>>>>pairs. As an object model I use an ArrayList that contains a bean.
>>>>Right next to each entry I want to have one "delete" commandLink that
>>>>contains the "name" of my bean as an attribute so that I can delete it
>>>>in the defined actionListener.
>>>>The problem I have is that the actionListener is not called at all for
>>>>some reason. I also get this error while the page is being rendered.
>>>>
>>>>Dec 4, 2004 12:46:45 PM net.sourceforge.myfaces.el.VariableResolverImpl
>>>>resolveVariable
>>>>SEVERE: Variable 'prefEntry' could not be resolved.
>>>>
>>>>Here is the JSP that is being rendered:
>>>><f:view>
>>>>    <h:form>
>>>>        <B><h:outputText value='#{myText.available_bookmarks}'/></B><br>
>>>>        <h:dataTable value="#{preferences.convertedPreferences}"
>>>>                     var="prefEntry">
>>>>            <h:column>
>>>>                <f:facet name="header">
>>>>                    <h:outputText value='#{myText.name}'/>
>>>>                </f:facet>
>>>>                <h:outputText value='#{prefEntry.name}'/>
>>>>            </h:column>
>>>>            <h:column>
>>>>                <f:facet name="header">
>>>>                    <h:outputText value='#{myText.url}'/>
>>>>                </f:facet>
>>>>                <h:outputText value='#{prefEntry.value}'/>
>>>>            </h:column>
>>>>            <h:column>
>>>>                <h:commandLink action="delete"
>>>>                               actionListener="#{bookmark.delete}">
>>>>                    <h:outputText value="#{myText.delete}" />
>>>>                    <f:attribute name="name" value="#{prefEntry.name}"/>
>>>>                </h:commandLink>
>>>>            </h:column>
>>>>        </h:dataTable>
>>>>    </h:form>
>>>></f:view>
>>>>
>>>>And here is the java source of the bean (BTW, I don't define this entry
>>>>bean in the faces-config - I tried, but it didn't make any difference):
>>>>
>>>>public class PreferenceEntryBean
>>>>{
>>>>       private String name;
>>>>       private String value;
>>>>
>>>>       /**
>>>>        * @return Returns the name.
>>>>        */
>>>>       public String getName() {
>>>>               return name;
>>>>       }
>>>>       /**
>>>>        * @param name The name to set.
>>>>        */
>>>>       public void setName(String name) {
>>>>               this.name = name;
>>>>       }
>>>>       /**
>>>>        * @return Returns the value.
>>>>        */
>>>>       public String getValue() {
>>>>               return value;
>>>>       }
>>>>       /**
>>>>        * @param value The value to set.
>>>>        */
>>>>       public void setValue(String value) {
>>>>               this.value = value;
>>>>       }
>>>>}
>>>>
>>>>Thanks for your help
>>>>Stephan
>>>>
>>>
>>>
>>>
>>
> 
> 


Re: Bug with dataTable ?

Posted by Heath Borders <he...@gmail.com>.
Ok, further assumptions:
You should have a managed bean called "bookmark" and it should have a
method with the following signature: "public void delete(ActionEvent
event)"

Is that the case?


On Sat, 04 Dec 2004 17:18:41 -0500, Stephan Hesmer <sh...@apache.org> wrote:
> Heath,
> 
> thanks for answering. Yes, all you wrote is correct. I have that bean, I
> have that in my configuration.
> After I read your mail I simply delete the line
> <f:attribute name="name" value="#{prefEntry.name}" />
> an retried my app.
> 
> The problem still persists - The ActionListener is not called.
> 
> here is my bookmark bean, which is also defined in the faces-config.
> 
> public class BookmarkBean implements java.io.Serializable
> {
>         private String name;
>         private String URL;
> 
>         public String getName() {
>                 return name;
>         }
>         public void setName(String name) {
>                 this.name = name;
>         }
>         public String getURL() {
>                 return URL;
>         }
>         public void setURL(String url) {
>                 URL = url;
>         }
> 
>         public void delete(ActionEvent event) throws
> AbortProcessingException {
>                 String name = (String)event.getComponent().getAttributes().get("name");
> 
>                 System.out.println("deleting name: "+name);
>         }
> 
> }
> 
> Thanks
> Stephan
> 
> 
> 
> Heath Borders wrote:
> > Here is what you should have:
> >
> > A faces-config managed bean named "preferences".
> >
> > Inside that bean, you need a read property for "convertedPreferences"
> > (probably a method called "getConvertedPreferences()" that returns
> > either an Array or a List.
> >
> > That Array or List should contain a PreferenceEntryBean which has the
> > getName/SetName, getValue/setValue methods.
> >
> > Most likely, your problem is with the following line of code:
> >
> > "<f:attribute name="name" value="#{prefEntry.name}" />
> >
> > What this line does is add the value of #{prefEntry.name}" to the
> > attribute Map of the parent commandLink under the key "name".  Most
> > likely, this will not get you anything, judging from your JSP.
> >
> > My guess is that you want a way for your ActionListener method to know
> > which row the user selected.  Fortunately, UIData's (which
> > HtmlDataTable extends), provides this facility.  When a UIComponent
> > contained within a UIData generates an event, the UIData must put the
> > request-scope variable of the row of that UIComponent on the request
> > scope.  This means that you can retrieve the prefEntry bean from the
> > row the user clicked by retrieving the bean from request scope.
> >
> >
> >
> > On Sat, 04 Dec 2004 12:54:05 -0500, Stephan Hesmer <sh...@apache.org> wrote:
> >
> >>Hi,
> >>
> >>I have a JSF application that uses a dataTable to display name/value
> >>pairs. As an object model I use an ArrayList that contains a bean.
> >>Right next to each entry I want to have one "delete" commandLink that
> >>contains the "name" of my bean as an attribute so that I can delete it
> >>in the defined actionListener.
> >>The problem I have is that the actionListener is not called at all for
> >>some reason. I also get this error while the page is being rendered.
> >>
> >>Dec 4, 2004 12:46:45 PM net.sourceforge.myfaces.el.VariableResolverImpl
> >>resolveVariable
> >>SEVERE: Variable 'prefEntry' could not be resolved.
> >>
> >>Here is the JSP that is being rendered:
> >><f:view>
> >>     <h:form>
> >>         <B><h:outputText value='#{myText.available_bookmarks}'/></B><br>
> >>         <h:dataTable value="#{preferences.convertedPreferences}"
> >>                      var="prefEntry">
> >>             <h:column>
> >>                 <f:facet name="header">
> >>                     <h:outputText value='#{myText.name}'/>
> >>                 </f:facet>
> >>                 <h:outputText value='#{prefEntry.name}'/>
> >>             </h:column>
> >>             <h:column>
> >>                 <f:facet name="header">
> >>                     <h:outputText value='#{myText.url}'/>
> >>                 </f:facet>
> >>                 <h:outputText value='#{prefEntry.value}'/>
> >>             </h:column>
> >>             <h:column>
> >>                 <h:commandLink action="delete"
> >>                                actionListener="#{bookmark.delete}">
> >>                     <h:outputText value="#{myText.delete}" />
> >>                     <f:attribute name="name" value="#{prefEntry.name}"/>
> >>                 </h:commandLink>
> >>             </h:column>
> >>         </h:dataTable>
> >>     </h:form>
> >></f:view>
> >>
> >>And here is the java source of the bean (BTW, I don't define this entry
> >>bean in the faces-config - I tried, but it didn't make any difference):
> >>
> >>public class PreferenceEntryBean
> >>{
> >>        private String name;
> >>        private String value;
> >>
> >>        /**
> >>         * @return Returns the name.
> >>         */
> >>        public String getName() {
> >>                return name;
> >>        }
> >>        /**
> >>         * @param name The name to set.
> >>         */
> >>        public void setName(String name) {
> >>                this.name = name;
> >>        }
> >>        /**
> >>         * @return Returns the value.
> >>         */
> >>        public String getValue() {
> >>                return value;
> >>        }
> >>        /**
> >>         * @param value The value to set.
> >>         */
> >>        public void setValue(String value) {
> >>                this.value = value;
> >>        }
> >>}
> >>
> >>Thanks for your help
> >>Stephan
> >>
> >
> >
> >
> 
> 


-- 
If you don't have a GMail account, I probably have 5 invites.  Just ask!
-Heath Borders-Wing
hborders@mail.win.org

Re: updateting x:dataTable content issues

Posted by Catalin Kormos <ca...@yahoo.com>.
I've found the answer, but can't tell that i realy
understand it; the answer: because i did't use a
navigation case to get the same page reloaded; i
tought it was't necesary, because if no navigation
case is found, AFAIK, JSF will always reload the same
page...; well, it does, but somehow then the data is
not refreshed as it should...

--- Catalin Kormos <ca...@yahoo.com> wrote:

> Hi,
> 
> I have a table that contains data over more than one
> page ; the user can do different actions on the
> content of the table, including the ability to
> select
> more than one row (by a checkbox found on first
> column), and click on a link to delete those rows;
> everything works fine, but when the user deletes a
> last row on a last page, the table would have to
> show
> the previous page, this would be normal, but instead
> it stay on the last page...which is wrong; i've
> tryied
> to set my self the "first" attribute's value of the
> dataTable, but is simply ignored, i do this in the
> same action method that deletes the selected rows.
> So
> it seems that after that, the backing bean doesn't
> get
> queryied about values, like the value for "first"
> and
> probably any other neider... Is there a workaround
> for
> this? or what is the preferred way to da content
> changes on a dataTable in general?
> 
> Thanks
> 
> 
> 		
> __________________________________ 
> Do you Yahoo!? 
> Yahoo! Mail - 250MB free storage. Do more. Manage
> less. 
> http://info.mail.yahoo.com/mail_250
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: updateting x:dataTable content issues - 2

Posted by Catalin Kormos <ca...@yahoo.com>.
I've found the answer, but can't tell that i realy
understand it; the answer: because i did't use a
navigation case to get the same page reloaded; i
tought it was't necesary, because if no navigation
case is found, AFAIK, JSF will always reload the same
page...; well, it does, but somehow then the data is
not refreshed as it should...

--- Catalin Kormos <ca...@yahoo.com> wrote:

> Another issue is this: the user can add rows into an
> existing dataTable; the rows are inserted, but when
> this action means that the page number increases,
> the
> dataScroller won't work normally...it seems that it
> does't gets updated, and when using the navigation
> actions will select always the first page...again,
> it
> raises me a question, i there any preferred way of
> doing these content updates, so that any related
> components will be aware of the changes? 
> 
> Thanks
> 
> 
> 	
> 		
> __________________________________ 
> Do you Yahoo!? 
> Yahoo! Mail - You care about security. So do we. 
> http://promotions.yahoo.com/new_mail
> 



		
__________________________________ 
Do you Yahoo!? 
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com 

updateting x:dataTable content issues - 2

Posted by Catalin Kormos <ca...@yahoo.com>.
Another issue is this: the user can add rows into an
existing dataTable; the rows are inserted, but when
this action means that the page number increases, the
dataScroller won't work normally...it seems that it
does't gets updated, and when using the navigation
actions will select always the first page...again, it
raises me a question, i there any preferred way of
doing these content updates, so that any related
components will be aware of the changes? 

Thanks


	
		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - You care about security. So do we. 
http://promotions.yahoo.com/new_mail

updateting x:dataTable content issues

Posted by Catalin Kormos <ca...@yahoo.com>.
Hi,

I have a table that contains data over more than one
page ; the user can do different actions on the
content of the table, including the ability to select
more than one row (by a checkbox found on first
column), and click on a link to delete those rows;
everything works fine, but when the user deletes a
last row on a last page, the table would have to show
the previous page, this would be normal, but instead
it stay on the last page...which is wrong; i've tryied
to set my self the "first" attribute's value of the
dataTable, but is simply ignored, i do this in the
same action method that deletes the selected rows. So
it seems that after that, the backing bean doesn't get
queryied about values, like the value for "first" and
probably any other neider... Is there a workaround for
this? or what is the preferred way to da content
changes on a dataTable in general?

Thanks


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - 250MB free storage. Do more. Manage less. 
http://info.mail.yahoo.com/mail_250

Re: Bug with dataTable ?

Posted by Stephan Hesmer <sh...@apache.org>.
Heath,

thanks for answering. Yes, all you wrote is correct. I have that bean, I 
have that in my configuration.
After I read your mail I simply delete the line
<f:attribute name="name" value="#{prefEntry.name}" />
an retried my app.

The problem still persists - The ActionListener is not called.

here is my bookmark bean, which is also defined in the faces-config.

public class BookmarkBean implements java.io.Serializable
{
	private String name;
	private String URL;
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getURL() {
		return URL;
	}
	public void setURL(String url) {
		URL = url;
	}
	
	public void delete(ActionEvent event) throws 		
AbortProcessingException {
		String name = (String)event.getComponent().getAttributes().get("name");
		
		System.out.println("deleting name: "+name);
	}
	
}

Thanks
Stephan

Heath Borders wrote:
> Here is what you should have:
> 
> A faces-config managed bean named "preferences".
> 
> Inside that bean, you need a read property for "convertedPreferences"
> (probably a method called "getConvertedPreferences()" that returns
> either an Array or a List.
> 
> That Array or List should contain a PreferenceEntryBean which has the
> getName/SetName, getValue/setValue methods.
> 
> Most likely, your problem is with the following line of code:
> 
> "<f:attribute name="name" value="#{prefEntry.name}" />
> 
> What this line does is add the value of #{prefEntry.name}" to the
> attribute Map of the parent commandLink under the key "name".  Most
> likely, this will not get you anything, judging from your JSP.
> 
> My guess is that you want a way for your ActionListener method to know
> which row the user selected.  Fortunately, UIData's (which
> HtmlDataTable extends), provides this facility.  When a UIComponent
> contained within a UIData generates an event, the UIData must put the
> request-scope variable of the row of that UIComponent on the request
> scope.  This means that you can retrieve the prefEntry bean from the
> row the user clicked by retrieving the bean from request scope.
> 
> 
> 
> On Sat, 04 Dec 2004 12:54:05 -0500, Stephan Hesmer <sh...@apache.org> wrote:
> 
>>Hi,
>>
>>I have a JSF application that uses a dataTable to display name/value
>>pairs. As an object model I use an ArrayList that contains a bean.
>>Right next to each entry I want to have one "delete" commandLink that
>>contains the "name" of my bean as an attribute so that I can delete it
>>in the defined actionListener.
>>The problem I have is that the actionListener is not called at all for
>>some reason. I also get this error while the page is being rendered.
>>
>>Dec 4, 2004 12:46:45 PM net.sourceforge.myfaces.el.VariableResolverImpl
>>resolveVariable
>>SEVERE: Variable 'prefEntry' could not be resolved.
>>
>>Here is the JSP that is being rendered:
>><f:view>
>>     <h:form>
>>         <B><h:outputText value='#{myText.available_bookmarks}'/></B><br>
>>         <h:dataTable value="#{preferences.convertedPreferences}"
>>                      var="prefEntry">
>>             <h:column>
>>                 <f:facet name="header">
>>                     <h:outputText value='#{myText.name}'/>
>>                 </f:facet>
>>                 <h:outputText value='#{prefEntry.name}'/>
>>             </h:column>
>>             <h:column>
>>                 <f:facet name="header">
>>                     <h:outputText value='#{myText.url}'/>
>>                 </f:facet>
>>                 <h:outputText value='#{prefEntry.value}'/>
>>             </h:column>
>>             <h:column>
>>                 <h:commandLink action="delete"
>>                                actionListener="#{bookmark.delete}">
>>                     <h:outputText value="#{myText.delete}" />
>>                     <f:attribute name="name" value="#{prefEntry.name}"/>
>>                 </h:commandLink>
>>             </h:column>
>>         </h:dataTable>
>>     </h:form>
>></f:view>
>>
>>And here is the java source of the bean (BTW, I don't define this entry
>>bean in the faces-config - I tried, but it didn't make any difference):
>>
>>public class PreferenceEntryBean
>>{
>>        private String name;
>>        private String value;
>>
>>        /**
>>         * @return Returns the name.
>>         */
>>        public String getName() {
>>                return name;
>>        }
>>        /**
>>         * @param name The name to set.
>>         */
>>        public void setName(String name) {
>>                this.name = name;
>>        }
>>        /**
>>         * @return Returns the value.
>>         */
>>        public String getValue() {
>>                return value;
>>        }
>>        /**
>>         * @param value The value to set.
>>         */
>>        public void setValue(String value) {
>>                this.value = value;
>>        }
>>}
>>
>>Thanks for your help
>>Stephan
>>
> 
> 
> 


Re: Bug with dataTable ?

Posted by Heath Borders <he...@gmail.com>.
Here is what you should have:

A faces-config managed bean named "preferences".

Inside that bean, you need a read property for "convertedPreferences"
(probably a method called "getConvertedPreferences()" that returns
either an Array or a List.

That Array or List should contain a PreferenceEntryBean which has the
getName/SetName, getValue/setValue methods.

Most likely, your problem is with the following line of code:

"<f:attribute name="name" value="#{prefEntry.name}" />

What this line does is add the value of #{prefEntry.name}" to the
attribute Map of the parent commandLink under the key "name".  Most
likely, this will not get you anything, judging from your JSP.

My guess is that you want a way for your ActionListener method to know
which row the user selected.  Fortunately, UIData's (which
HtmlDataTable extends), provides this facility.  When a UIComponent
contained within a UIData generates an event, the UIData must put the
request-scope variable of the row of that UIComponent on the request
scope.  This means that you can retrieve the prefEntry bean from the
row the user clicked by retrieving the bean from request scope.



On Sat, 04 Dec 2004 12:54:05 -0500, Stephan Hesmer <sh...@apache.org> wrote:
> Hi,
> 
> I have a JSF application that uses a dataTable to display name/value
> pairs. As an object model I use an ArrayList that contains a bean.
> Right next to each entry I want to have one "delete" commandLink that
> contains the "name" of my bean as an attribute so that I can delete it
> in the defined actionListener.
> The problem I have is that the actionListener is not called at all for
> some reason. I also get this error while the page is being rendered.
> 
> Dec 4, 2004 12:46:45 PM net.sourceforge.myfaces.el.VariableResolverImpl
> resolveVariable
> SEVERE: Variable 'prefEntry' could not be resolved.
> 
> Here is the JSP that is being rendered:
> <f:view>
>      <h:form>
>          <B><h:outputText value='#{myText.available_bookmarks}'/></B><br>
>          <h:dataTable value="#{preferences.convertedPreferences}"
>                       var="prefEntry">
>              <h:column>
>                  <f:facet name="header">
>                      <h:outputText value='#{myText.name}'/>
>                  </f:facet>
>                  <h:outputText value='#{prefEntry.name}'/>
>              </h:column>
>              <h:column>
>                  <f:facet name="header">
>                      <h:outputText value='#{myText.url}'/>
>                  </f:facet>
>                  <h:outputText value='#{prefEntry.value}'/>
>              </h:column>
>              <h:column>
>                  <h:commandLink action="delete"
>                                 actionListener="#{bookmark.delete}">
>                      <h:outputText value="#{myText.delete}" />
>                      <f:attribute name="name" value="#{prefEntry.name}"/>
>                  </h:commandLink>
>              </h:column>
>          </h:dataTable>
>      </h:form>
> </f:view>
> 
> And here is the java source of the bean (BTW, I don't define this entry
> bean in the faces-config - I tried, but it didn't make any difference):
> 
> public class PreferenceEntryBean
> {
>         private String name;
>         private String value;
> 
>         /**
>          * @return Returns the name.
>          */
>         public String getName() {
>                 return name;
>         }
>         /**
>          * @param name The name to set.
>          */
>         public void setName(String name) {
>                 this.name = name;
>         }
>         /**
>          * @return Returns the value.
>          */
>         public String getValue() {
>                 return value;
>         }
>         /**
>          * @param value The value to set.
>          */
>         public void setValue(String value) {
>                 this.value = value;
>         }
> }
> 
> Thanks for your help
> Stephan
> 


-- 
If you don't have a GMail account, I probably have 5 invites.  Just ask!
-Heath Borders-Wing
hborders@mail.win.org