Giter Site home page Giter Site logo

Comments (20)

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
Reported by rogerk

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
rogerk said:
The original tightly coupled renderer dependency was introduced as a solution
for bugster bug: 5055795 (command link/multiple forms/back button problem).

M src/com/sun/faces/RIConstants.java

  • introduce new constant to identify stored component attribute data
    M src/com/sun/faces/renderkit/html_basic/CommandLinkRenderer.java
  • stash a hidden field (identifying this command link) in a map;
  • stash the map as attribute data in this command link's form component;
  • store param data associated with this link using the param's "value"
    • not "name* - because "name is not required - and if no name is specified,
      HtmlResponseWriter will throw NPE (per spec)..
      M src/com/sun/faces/renderkit/html_basic/FormRenderer.java
  • render any hidden field information from stored map in Form component;
  • make addNeededHiddenField/addRenderedHiddenField/getHiddenFieldMap
    private non static helper methods (not sure if these are still needed)..
    M src/com/sun/faces/renderkit/html_basic/HiddenRenderer.java
  • remove FormRenderer.addRenderedHiddenField call
    M systest/web/golden/taglib/commandLink_test.txt
  • new golden file
    M web/test/RenderResponse_correct
  • new golden file

Index: RIConstants.java

RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/RIConstants.java,v
retrieving revision 1.67
diff -u -r1.67 RIConstants.java
— RIConstants.java 26 Jul 2004 21:12:43 -0000 1.67
+++ RIConstants.java 2 Aug 2004 12:36:35 -0000
@@ -98,6 +98,11 @@

public static boolean IS_UNIT_TEST_MODE = false;

  • /**
    • Can be used as the name of stored component attribute data

  • */
  • public static final String COMPONENT_DATA = "component-data";

/*

  • TLV Resource Bundle Location

    */

Index: FormRenderer.java

RCS file:
/cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/renderkit/html_basic/FormRenderer.java,v
retrieving revision 1.78
diff -u -r1.78 FormRenderer.java
— FormRenderer.java 28 Apr 2004 20:59:41 -0000 1.78
+++ FormRenderer.java 2 Aug 2004 12:28:28 -0000
@@ -212,22 +212,17 @@
throws IOException {

ResponseWriter writer = context.getResponseWriter();

  • Map map = getHiddenFieldMap(context, false);
    +

    • Map map = (Map)component.getAttributes().get(RIConstants.COMPONENT_DATA);
      if (map != null) {
      Iterator entries = map.entrySet().iterator();
      while (entries.hasNext()) {
      Map.Entry entry = (Map.Entry) entries.next();
  • if (Boolean.TRUE.equals(entry.getValue())) { - writer.startElement("input", component); - writer.writeAttribute("type", "hidden", null); - writer.writeAttribute("name", entry.getKey(), null); - writer.endElement("input"); - }

    • writer.startElement("input", component);
    • writer.writeAttribute("type", "hidden", null);
    • writer.writeAttribute("name", entry.getKey(), null);
    • writer.endElement("input");
      }
    • // Clear the hidden field map
    • Map requestMap = context.getExternalContext().getRequestMap();
    • requestMap.put(HIDDEN_FIELD_KEY, null);
      }
      }

    @@ -235,7 +230,7 @@
    /**

    • Remember that we will need a new hidden field.

    */

    • public static void addNeededHiddenField(FacesContext context,
    • private void addNeededHiddenField(FacesContext context,
      String clientId) {
      Map map = getHiddenFieldMap(context, true);
      if (!map.containsKey(clientId)) { @@ -243,18 +238,17 @@ }
      }

    /**

    • Note that a hidden field has already been rendered.

    */

    • public static void addRenderedHiddenField(FacesContext context,
    • private void addRenderedHiddenField(FacesContext context,
      String clientId) { Map map = getHiddenFieldMap(context, true); map.put(clientId, Boolean.FALSE); }
    • private static Map getHiddenFieldMap(FacesContext context,
    • private Map getHiddenFieldMap(FacesContext context,
      boolean createIfNew) {
      Map requestMap = context.getExternalContext().getRequestMap();
      Map map = (Map) requestMap.get(HIDDEN_FIELD_KEY);
      rogerk@bruins:~/jsf/javaserverfaces-sources/jsf-ri/src/com/sun/faces/renderkit/html_basic>
      cvs diff -u *.java
      Index: CommandLinkRenderer.java
      ===================================================================
      RCS file:
      /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/renderkit/html_basic/CommandLinkRenderer.java,v
      retrieving revision 1.22
      diff -u -r1.22 CommandLinkRenderer.java
      — CommandLinkRenderer.java 8 Jun 2004 13:47:28 -0000 1.22
      +++ CommandLinkRenderer.java 2 Aug 2004 12:35:25 -0000
      @@ -26,6 +26,7 @@
      import javax.faces.event.ActionEvent;

    import java.io.IOException;
    +import java.util.HashMap;
    import java.util.Iterator;
    import java.util.Map;

    @@ -213,7 +214,7 @@
    sb.append(formClientId);
    sb.append("'");
    sb.append("]['");

    • sb.append(paramList[i].getName());
    • sb.append(paramList[i].getValue());
      sb.append("'].value='");
      sb.append(paramList[i].getValue());
      sb.append("';");
      @@ -313,10 +314,10 @@
      writer.endElement("a");

    //Handle hidden fields

    //Only need one hidden field for the link itself per form.

    • FormRenderer.addNeededHiddenField(context,
    • getHiddenFieldName(context, command));
    • String hiddenFieldName = getHiddenFieldName(context, command);
    • Map map = new HashMap();
    • map.put(hiddenFieldName, hiddenFieldName);

    // PENDING(edburns): not sure if the JSFA59 back button problem
    // manifests itself with param children as well...
    @@ -324,8 +325,10 @@
    // get UIParameter children...
    Param paramList[] = getParamList(context, command);
    for (int i = 0; i < paramList.length; i++) { - FormRenderer.addNeededHiddenField(context, paramList[i].getName()); + map.put(paramList[i].getValue(), paramList[i].getValue()); }

    • UIForm form = getMyForm(context, command);
    • form.getAttributes().put(RIConstants.COMPONENT_DATA, map);
      if (log.isTraceEnabled()) { log.trace("End encoding component " + component.getId()); }
      Index: FormRenderer.java
      ===================================================================
      RCS file:
      /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/renderkit/html_basic/FormRenderer.java,v
      retrieving revision 1.78
      diff -u -r1.78 FormRenderer.java
      — FormRenderer.java 28 Apr 2004 20:59:41 -0000 1.78
      +++ FormRenderer.java 2 Aug 2004 12:35:25 -0000
      @@ -212,22 +212,17 @@
      throws IOException {

    ResponseWriter writer = context.getResponseWriter();

    • Map map = getHiddenFieldMap(context, false);
    • Map map = (Map)component.getAttributes().get(RIConstants.COMPONENT_DATA);
      if (map != null) {
      Iterator entries = map.entrySet().iterator();
      while (entries.hasNext()) {
      Map.Entry entry = (Map.Entry) entries.next();
    • if (Boolean.TRUE.equals(entry.getValue())) { - writer.startElement("input", component); - writer.writeAttribute("type", "hidden", null); - writer.writeAttribute("name", entry.getKey(), null); - writer.endElement("input"); - }
    • writer.startElement("input", component);
    • writer.writeAttribute("type", "hidden", null);
    • writer.writeAttribute("name", entry.getKey(), null);
    • writer.endElement("input");
      }
  • // Clear the hidden field map

  • Map requestMap = context.getExternalContext().getRequestMap();

  • requestMap.put(HIDDEN_FIELD_KEY, null);
    }
    }

@@ -235,7 +230,7 @@
/**

  • Remember that we will need a new hidden field.

    */
  • public static void addNeededHiddenField(FacesContext context,

    • private void addNeededHiddenField(FacesContext context,
      String clientId)Unknown macro: { Map map = getHiddenFieldMap(context, true); if (!map.containsKey(clientId)) { @@ -243,18 +238,17 @@ } }

/**

  • Note that a hidden field has already been rendered.

    */
  • public static void addRenderedHiddenField(FacesContext context,

    • private void addRenderedHiddenField(FacesContext context,
      String clientId) { Map map = getHiddenFieldMap(context, true); map.put(clientId, Boolean.FALSE); }
  • private static Map getHiddenFieldMap(FacesContext context,

    • private Map getHiddenFieldMap(FacesContext context,
      boolean createIfNew) { Map requestMap = context.getExternalContext().getRequestMap(); Map map = (Map) requestMap.get(HIDDEN_FIELD_KEY); Index: HiddenRenderer.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/renderkit/html_basic/HiddenRenderer.java,v retrieving revision 1.20 diff -u -r1.20 HiddenRenderer.java --- HiddenRenderer.java 31 Mar 2004 18:48:35 -0000 1.20 +++ HiddenRenderer.java 2 Aug 2004 12:35:25 -0000 @@ -97,8 +97,6 @@ writer.writeAttribute("value", currentValue, "value"); }

    writer.endElement("input");

  • FormRenderer.addRenderedHiddenField(context, clientId);
    }
    // The testcase for this class is TestRenderers_3.java

Index: commandLink_test.txt

RCS file:
/cvs/javaserverfaces-sources/jsf-ri/systest/web/golden/taglib/commandLink_test.txt,v
retrieving revision 1.5
diff -u -r1.5 commandLink_test.txt
— commandLink_test.txt 12 May 2004 04:35:07 -0000 1.5
+++ commandLink_test.txt 2 Aug 2004 12:37:52 -0000
@@ -11,17 +11,17 @@

  • +

My
Link

This is a String property
RES-BUNDLE LINK

Index: RenderResponse_correct

RCS file: /cvs/javaserverfaces-sources/jsf-ri/web/test/RenderResponse_correct,v
retrieving revision 1.109
diff -u -r1.109 RenderResponse_correct
— RenderResponse_correct 28 Jul 2004 20:36:17 -0000 1.109
+++ RenderResponse_correct 2 Aug 2004 12:38:39 -0000
@@ -15,7 +15,7 @@

-


+

@@ -130,12 +130,12 @@
@@ -153,7 +153,7 @@

@@ -169,7 +169,7 @@

@@ -177,7 +177,7 @@

@@ -189,12 +189,12 @@

@@ -202,7 +202,7 @@

@@ -212,13 +212,13 @@

@@ -228,7 +228,7 @@

@@ -846,7 +846,7 @@
Param 0: my param

-
+

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
rogerk said:
The spec needs clarification changes with regards to
CommandLinkRenderer/FormRenderer responsibilities. The spec should outline in
more detail the steps that one would need to do for their own implementation.
The current implementation has tightly coupled FormRenderer/CommandLinkRenderer
dependencies (CommandLinkRenderer invokes static FormRenderer methods). The
spec should outline (in detail) another (less dependent) way of getting multiple
commandLinks in one or more forms to work. In addition, any "param" children
nested within a commandLink, must specify a parameter name - since this is
used as a hidden field name (this should also be more clear in the spec). The
change bundle (specified prior) is one possible solution - with one correction -
we should use param "name" (not "value") as the hiddden field name for
parameter children of commandLink(s).

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
rogerk said:
Additional comments from Adam:
Roger Kitain wrote:

Hey Adam -

Now that I've got your attention...
If you get a chance look at issue 26 in java.net land (faces).
We are trying to do away with this "hard coded" dependency between
FormRenderer/CommandLinkRenderer - (essentially-find another way
of accomplishing the same functionality but without having to
use FormRenderer static method calls in CommandLinkRenderer.
I thought of at least doing something like having the CommandLinkRenderer
stuff some hidden field info into it's parent Form component attribute - so
the FormRenderer could use it when rendering the hidden fields.

What do you think?

(Cc'ing the main dev list)

I see a few categories of potential solutions:

(1) Client-side Javascript solutions
(2) Break the dependency
(3) Keep the dependency, but make it a public API
(4) Dynamically add HtmlInputHidden components.

1. Client-side Javascript solutions

Instead of trying to create fields
on the server, use DHTML to dynamically create DOM nodes
for these fields as needed. This is tricky for a bunch
of reasons (you'd want to rely on a helper script,
for one - who's responsible for writing this script?)
It's worth looking down this road later for other problems,
but for now, let's forget about it.

2. Break the dependency:

Instead of relying on FormRenderer to output the hidden
fields, each CommandLink would output its hidden field
immediately, but only after checking that the hidden
field hadn't already been rendered by a different
CommandLink. Problems include:

  • How do you detect that you aren't in a different
    UIForm, and that the set of rendered hidden fields
    needs to be reset?
  • Even if you solve the "I'm in a different UIForm"
    case, you still have a dependency betwen
    CommandLinkRenderer and the Basic HTML RenderKit
    concept that "UIForms are what render HTML s";
    this is a questionable assumption at best.
  • The moment you add a second component that needs
    to output hidden fields dynamically, you're back
    in the same boat with inter-renderer dependencies.

3. Keep the dependency, but make it a public API

Expose a public contract: for example, assert that
a java.util.Set of needed names is added at a certain
key at request scope. This works, but has its own set of
problems:

  • We can't do so until 1.2 at the earliest, since this
    is a spec change.
  • Will this approach generalize going forward? Do we need
    a more generic solution at the component level? For
    example, future support for client-side validation may
    add dependencies between <h:inputText> and <h:form>; what
    APIs would be needed to generalize that dependency?

4. Dynamically add HtmlInputHidden components

CommandLinkRenderer finds the UIForm and dynamically
creates and adds HtmlInputHidden components as needed
to render the needed hidden fields. Getting this
approach to work with the current JSF/JSP integration
seems hopeless.

Category #2 is the closest I can see to a tractable
approach to solving this issue in the 1.1 timeframe,
but my gut feeling is that it should be punted on for
1.1 altogether.

– Adam


To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
rogerk said:
The spec side of this issue wil be handled here:

https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=12

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
jayashri said:
Issue targeted for JSF 1.2

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
@edburns said:
Take ownership.

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
@edburns said:
Created an attachment (id=57)
change-bundle

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
jayashri said:
I think casting to ServletResponse might pose a problem in the Portlet
Environment although I am not 100% sure about that. If its not too much of a
problem, can we introduce a getContentType() method on ExternalContext to be on
the safe side?
Thanks

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
@edburns said:
Created an attachment (id=58)
change-bundle

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
jayashri said:
CommandButton and CommandLink renderers use different ways to find its nearest
form element if interpreted the diffs correctly.

CommandButton

  • while (!myForm.getFamily().equals("javax.faces.Form") && root != myForm)

{ + myForm = myForm.getParent(); + }

commandLink
while (parent != null) {
if (parent instanceof UIForm)

{ break; }

parent = parent.getParent();
}

Shouldn't it be consistent ?

Otherwise looks great.
r=jayashri

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
@edburns said:
Fix checked in, including Jayashri's suggestion.

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
@edburns said:
While merging wta-head into jsf-head, I discovered another bug.

The HiddenRenderer needs to make sure that its values are cleared when the
"clear" script is executed. This leads to a contract between the HiddenRenderer
and the CommandLinkRenderer. We currently don't do this, creating a back buttor
problem:

— src/com/sun/faces/renderkit/html_basic/HiddenRenderer.java 2005-04-21
14:55:36.000000000 -0400
+++
/home/edburns/Projects/J2EE/workareas/webtier-alignment-trunk/prototype/jsf-ri/src/com/sun/faces/renderkit/html_basic/HiddenRenderer.java
2005-05-02 17:23:17.000000000 -0400
@@ -1,5 +1,5 @@
/*

    • $Id: HiddenRenderer.java,v 1.23 2005/04/21 18:55:36 edburns Exp $
      • $Id: HiddenRenderer.java,v 1.4 2005/03/31 16:39:17 edburns Exp $
        */

/*
@@ -89,6 +89,8 @@
writer.writeAttribute("value", currentValue, "value");
}
writer.endElement("input");
+

  • FormRenderer.addRenderedHiddenField(context, clientId);
    }

// The testcase for this class is TestRenderers_3.java

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
@edburns said:
After talking to Jayashri, I realize that we don't need to clear out the values
from h:inputHidden fields in the page. These values should be submitted
regardless of any commandLinks in the page.

Closing.

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
@manfredriem said:
Closing issue out

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
File: message.txt
Attached By: @edburns

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
File: message.txt
Attached By: @edburns

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
This issue was imported from java.net JIRA JAVASERVERFACES-26

from mojarra.

ren-zhijun-oracle avatar ren-zhijun-oracle commented on July 16, 2024

@javaserverfaces Commented
Marked as fixed on Wednesday, April 19th 2006, 5:44:08 am

from mojarra.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.