0

I have the following inside a richfaces modalpanel:

<ui:repeat id="al11" var="albumslistvalue1" value="#{AlbumDetailBean.getAlbumImagesList()}"
varStatus="albumslistvalue1Index">
  <rich:modalPanel id="panel#{albumslistvalue1Index}" width="850" height="560">
    <f:facet name="header">
      <h:panelGroup>
        <h:outputText value="Fotos"/>
      </h:panelGroup>
    </f:facet>
    <f:facet name="controls">
      <h:panelGroup>
        <h:graphicImage value="/img/modal/close.png" styleClass="hidelink" id="hidelink"/>
        <rich:componentControl for="panel" attachTo="hidelink" operation="hide"
        event="onclick" />
      </h:panelGroup>
    </f:facet>
    <!-- content-->
    <center>
      <h:graphicImage value="img/cart/prior16.png" />
      <h:graphicImage value="albums/#{albumslistvalue1.albumImageId}/med_#{albumslistvalue1.albumimagename}"/>
      <h:graphicImage value="img/cart/next16.png" />
      <h:commandLink id="comp" action="#{AlbumDetailBean.getCartAlbums()}">
        <div>
          <h:outputText value="Comprar" />
          <f:param name="albumproductid" value="#{albumslistvalue1.id}" />
        </div>
      </h:commandLink>
    </center>
  </rich:modalPanel>
  <h:outputLink value="#" id="link">
    <!-- Show Modal Panel -->
    <h:graphicImage id="image" url="albums/#{albumslistvalue1.albumImageId}/mini_#{albumslistvalue1.albumimagename}"
    width="100px" height="auto" />
    <rich:componentControl for="panel#{albumslistvalue1Index}" attachTo="link"
    operation="show" event="onclick" />
  </h:outputLink>
</ui:repeat>

and getCartAlbums() method:

public List getCartAlbums() {
  boolean status = false;
  AlbumImpl bean1 = new AlbumImpl();

  String productidval = ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getParameter("albumproductid");

  AlbumDetailBean albums = (AlbumDetailBean) bean1.bo_getAlbumImageDetails(productidval);

  if(albums != null) {

    cartAlbumDetails.add(albums);
    setId(albums.getId());
    setAlbumname(albums.getAlbumname());
    setSchoolId(albums.getSchoolId());
    setAlbumImageId(albums.getAlbumImageId());
    setAlbumimagename(albums.getAlbumimagename());
    // setAlbumimage(albums.getAlbumimage());
    setListPrice(albums.getListPrice());
    setAvailableQty(albums.getAvailableQty());
    setTotalAmount(albums.getTotalAmount());
    setProductcode(albums.getProductcode());
    setListpricevalue(albums.getListpricevalue());
    setProductsize(albums.getProductsize());
    setQtyvalue(albums.getQtyvalue());
    setTotalpricevalue(albums.getTotalpricevalue());
    setProductid(albums.getProductid());
    setShipPrice(albums.getShipPrice());
  }
  return cartAlbumDetails;
}

I'm using someone else's code, so i didn't write the getCartAlbums() method, but it basically add the select image to the cart, it's working, the images are added to the cart correctly, but the modalpanel still closes

4

1 回答 1

0

I think you're using JSF 1/RF3? getCartAlbums() is returning a list, is this right? My JSF 1 knowledge is from the distant past but it doesn't look right.

However, the problem is that the h:commandLink is doing a full page submit, a POST request which reloads the page with the results of the postback (the response to the POST request). So after the button is pushed you see the screen redraw and what you're seeing is the page in the same state (albeit with updated values) as it was in when you first loaded it, which is without a modalPanel.

To remedy the problem you want to use a4j:commandLink to perform an ajax partial submit. I'm not sure if RF3 has execute= and render= attributes on the a4j:commandLink component or whether you have to use a4j:support as a child component, but I'm sure you can find out. You use execute= to specify which components values are submitted in the body of the ajax POST request, and render= to specify which components are updated after the postback is received.

于 2012-08-09T14:24:50.727 回答