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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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










Reply via email to