Bug 167180 - [faces-config editor] Creating invalid from-action in navigation cases
Summary: [faces-config editor] Creating invalid from-action in navigation cases
Status: RESOLVED FIXED
Alias: None
Product: Java Server Faces
Classification: WebTools
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: 3.0 RC1   Edit
Assignee: Gerry Kessler CLA
QA Contact:
URL:
Whiteboard: PMC_approved
Keywords: contributed, readme
Depends on:
Blocks:
 
Reported: 2006-12-07 17:59 EST by Cameron Bateman CLA
Modified: 2008-09-15 19:44 EDT (History)
6 users (show)

See Also:
david_williams: pmc_approved+
raghunathan.srinivasan: pmc_approved? (naci.dai)
raghunathan.srinivasan: pmc_approved? (deboer)
raghunathan.srinivasan: pmc_approved? (neil.hauge)
raghunathan.srinivasan: pmc_approved? (kaloyan)
raghunathan.srinivasan: review+


Attachments
proposed fix (49.89 KB, patch)
2008-05-06 15:00 EDT, Scott Paxton CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cameron Bateman CLA 2006-12-07 17:59:15 EST
The Faces Config Editor is not ensuring that navigation case "from-action" element values correspond to expected syntax.  In Faces 1.2, this becomes a bigger problem (although it's also true in 1.1) since the XSD schema flags a pattern match error.

The syntax must match EL syntax, i.e. #{var.prop}.
Comment 1 Raghunathan Srinivasan CLA 2007-01-05 20:23:22 EST
Triaged for WP 2.0.
Comment 2 Raghunathan Srinivasan CLA 2007-04-13 17:23:26 EDT
Consider for 3.0
Comment 3 Raghunathan Srinivasan CLA 2008-04-14 19:01:14 EDT
Deferred due to lack of resources.
Comment 4 Yury Kats CLA 2008-04-28 14:00:07 EDT
This is really confusing to the end user, since as long as you add a navigation rule (through the editor's UI!) the faces-config is marked with two errors. The user obviously didn't do anything wrong, why the errors? And, of course, the errors are cryptic enough to confuse the user and not make it clear how to fix the problem.

This is what I see in the Problems view:

cvc-complex-type.2.2: Element 'from-action' must have no element [children], and the value must be valid
cvc-pattern-valid: Value '
			#{pc_P1.doButton1Action}' is not facet-valid with respect to pattern '#\{.*\}' for type 'faces-config-el-expressionType'.
Comment 5 Raghunathan Srinivasan CLA 2008-04-28 17:21:00 EDT
I agree the error is confusing to the users and is not easy to resolve. We will review this bug in detail, but it could be an issue with a subsystem.

Workaround: Removing the whitesapace around the  from-action element fixes the issue:
<from-action>#{loginBean.doLogin}</from-action>
Comment 6 Scott Paxton CLA 2008-05-06 15:00:10 EDT
Created attachment 98919 [details]
proposed fix
Comment 7 Scott Paxton CLA 2008-05-06 15:00:58 EDT
I looked at this problem and found that it's related to the use of getTextContent() as the getter for an element's body text (which is signified by using the TEXT_ATTRIBUTE_VALUE constant for a Translator class).  I found a similar situation with the web.xml EMF model and that example put me on the track of using a slightly different constructor in the Translator classes for the various faces-config elements.  

If instead of using this call to the super constructor:

public FromActionTranslator(String domNameAndPath, EStructuralFeature aFeature) {
	super(domNameAndPath, aFeature);
}

we instead use ...

public FromActionTranslator(String domNameAndPath, EStructuralFeature aFeature) {
	super(domNameAndPath, aFeature, END_TAG_NO_INDENT);
}

... then the additional END_TAG_NO_INDENT parameter causes the emitted XML to be properly written wihtout linebreaks and extraneous indenting as a continuous start-tag/body/end-tag string.  Not only does this fix the reported problem which affects all pattern-based strings in the schema, but it also improves readability of the total faces-config file.

I've attached a proposed patch that makes this change for all the "text content" elements in the EMF model.
Comment 8 Raghunathan Srinivasan CLA 2008-05-07 10:02:59 EDT
Thanks for looking into this issue and the patch. We will review the patch.

If this is an issue that must be fixed in 3.0, please raise the Priority on the bug.
Comment 9 Scott Paxton CLA 2008-05-07 10:25:22 EDT
I can't seem to change the priority myself but we would really like this fix in 3.0.  Could somebody bump it up?  Thanks.
Comment 10 Raghunathan Srinivasan CLA 2008-05-09 15:56:00 EDT
The Faces Config Editor incorrectly reports error and as detailed in Comment 4, this is confusing to the user and there is no obvious way for the user to 'fix' the error.

This is an adopter requested fix. We have reviewed the patch and find it safe and low risk. Requesting PMC approval.
Comment 11 David Williams CLA 2008-05-09 16:00:37 EDT
Well ... since it's for Scott ... :) 

Comment 12 Gerry Kessler CLA 2008-05-09 17:20:40 EDT
Patch checked-in 5/9/08.
Comment 13 Cameron Bateman CLA 2008-06-19 12:45:22 EDT
This only fixes part of the original issue.  I can still enter "foo" for the from-action in the navigation rule property editor (right-click on the link between two nodes in the navigation editor and select "Show Properties"), and it allows the source to be updated with it.  

The syntax must match the #{} EL expression to be correct.  It will flagged immediately by the WST schema validator if the file is >=1.2 and our own JSF validator will flag it if it's <=1.1.

The editor should not allow the user to accept data values that it can easily verify are incorrect.
Comment 14 Gerry Kessler CLA 2008-09-15 19:40:52 EDT
Re-marking as fixed.   Bug has been cloned as bug 247274 for future consideration.
Comment 15 Gerry Kessler CLA 2008-09-15 19:44:20 EDT
Typo above.   Bug has been cloned as bug 247374 for future
consideration.