Is there any chance to get the html content (mime) from a rich text component without any datasource. I would like to grab the content from the field like this. getComponent("FieldName").value but this dosen't work.
thanks.
You can bind the control to a scoped variable; for example, #{viewScope.comments}. You can then retrieve the submitted value from the scope instead of from the component itself; for example, viewScope.get("comments").
Alternatively, you can set a dataContext variable to a JS expression, e.g. <dataContext var="richText" value="#{javascript:return {value:""};}" />. Then you can bind the control to #{richText.value} and retrieve it via the same expression.
And, of course, you could define a managed bean and bind the control to one of its properties. This option provides the most flexibility, but isn't quite as simple as the other two options above.
The solution for my problem is
getComponent("FieldName").getValue()
thanks for your help.
Related
I'm refactoring an XPages application which has five nested repeat controls repeating basically the same thing (an xp:panel). I thought, aha, here comes a custom control with properties!
I'm looping my repeat controls around properties of a managed bean, and I was hoping I could have set a property for the custom control to just accept the POJO I'm sending it (and then access it with EL within the custom control).
What should I do? Make the custom control receive only strings, numbers, etc and have the whole nested-control logic outside? Or is there a trick?
A custom control can easily accept a java object that's passed in via the custom properties. Just use the type: java.lang.Object
All the answers were correct, but only David put it as an answer - thanks to all!
I've noted my code here for anyone later: I defined node to be of Type java.lang.Object. Notice the syntax to get the object into the custom control:
<xp:repeat
id="repeatfirstlevelnode"
value="#{TableOfContents.root.children}"
var="firstlevelnode">
<xc:ccPanelNavigation
node="#{firstlevelnode}"
panelStyleWhenActive="panelLevel1 active bold"
panelStyleWhenInactive="panelLevel1"
NameNestedRepeatControl="repeatsecondlevelnodes">
</xc:ccPanelNavigation>
And once you're in the custom control, you access the property with CompositeData.YourObject.
<xp:image
id="imgDummy"
url="/dummyEC.png"
styleClass="imageDummy">
<xp:this.rendered><![CDATA[#{not compositeData.node.hasChildren}]]></xp:this.rendered>
</xp:image>
I'm currently building a custom control to be used as an application's view navigator (classic OneUI style). First of all: this is a 8.5.3 based project, and unfortunately there's no way to use Extlib stuff or other extensions / plug-ins. So we have to build all the tricky stuff ourselves using only what came "out-of-the-box" with 8.5.3.
I'd llike to build my navigator using a repeat control containing <xp:link> controls. Datasource could be an array of javascript objects where each single object would look like this:
var navEntry = {"entryLabel" : "label-of-link",
"entryTarget" : "target-url-of-link",
"entryStyle" : "style-to-emphasize-selected-link"}
Each array element then would describe a single navigator entry.
Since the navigator will be used in all possible "DominoView" Xpages it yould make sense to build the array of JS objects at the Xpage level and then pass that info into the custom control.
I'm aware that there are multiple ways to do this, and one could be "Custom Control Properties". If there was a way to pass my JS object array.
(Hope I could make clear what I'm trying to do here...)
That object looks like a HashMap to me really. You should be able to pass that in to a custom control via custom property if you use the type java.util.HashMap I'd think. You'll need to type it in I'm sure. I've passed custom objects in by using java.lang.Object.
The custom control will get loaded during the Page Load event, and usually properties have to be available at that point. If they're loaded during the Render Response phase, that's too late. So your SSJS object will need to be Compute on Page Load.
To use contents of a repeat control, you would need to set repeatControls=true, otherwise the repeat is only built during render response. Until then it's just a single set of controls with no data in them. However, Im pretty sure repeatControls="true" means you only get the number of rows you define. You can't change it via a pager.
You can manually define the type of the custom property. For a standard SSJS Object you use "com.ibm.jscript.std.ObjectObject", for a SSJS Array you use "com.ibm.jscript.std.ArrayObject" etc. As editor for the custom property, I set the string editor ("String value").
I have a template in JSF, this template have a button whose action must be different for each page that will use this template.
I wonder if there is any way to set only a part of that action.
Eg
In the template, I have the following attribute on the button:
disabled = "#{managedBeanTemplate.EditMode}"
However, for each page that will use this template, it should replace ONLY the part where it says managedBeanTemplate, thus:
disabled = "#{managedBeanProduct.EditMode}"
disabled = "#{managedBeanSales.EditMode}"
Is there any way to do this?
I know there is the ui:param to replace parts of the xhtml, but i can't nest in the template using something like this:
disabled = "#{#{managedBeanName}.EditMode}"
in the template, and then
<ui:param name="managedBeanName" value="managedBeanProduct"/>
in the page that uses the template.
I found the answer here:
facelets: passing bean name with ui:param to action attribute
i can just do something like this in the template:
disabled = "#{managedBeanName['EditMode']}"
then, i can simply set the "managedBeanName" through the ui:param
you would be better served having method that takes a parameter. by having the template construct the back references to the server side you are creating a maintainance footprint where it should not be. replace the references with a method that abstracts away the logic of whether the component is disabled/rendered/etc.
ultimately the UX should not care "why", just whether it has to render a compoenent a certain way.
Has anyone experienced an issue with disableOutputTag property where if you disable output tag for a computed field control inside a repeat control and have ssjs computed content inside that tag, it won't compute the content? Is disableOutputtag property only meant to work with static content inside a repeat control or is it a bug?
I don't know whether its a bug or not, but you can emulate the behavior of disableOutputTag by removing the ID attribute from and setting the disableTheme attribute to true. Maybe this helps you in short term.
EDIT: You can refer here for more information.
Not only does this happen when placing the xp:Text control inside a repeat but in also when you create a new XPage, add a xp:text onto it and define its value like:
<xp:text value="This is a test" disableOutputTag="true"/>
In the above example the xp:text will disappear. This is not what you would have expected. I would expect that only the value would be visible on the rendered page. But I think I can explain why this happens. Since there are no tags defined (disableoutputtag) somewhere in the rendered of this component it states that it should not generate anything. Because it can not bind its id to 'nothing' and so on.
Anyway, I could not think of a scenario where I would like to render plain text without any surrounding tags. It should at least be surrounded by a span or paragraph (<p>) tag so you can style it. And an ID would be nice so I can change the contents with a partial refresh.
I have a form which one of it's fields is a code and description, also a button for opening a popup window that contains a list of all of the available codes.
when the user double clickes a row from that table i want to set these values to the code and description. - how can this be done?
Another question, I want to create this popup and table to be initialized dynamically - by that i mean that if i have a few forms in my application, when ever i have a field which has a description i want to be able to open this popup and to see the available list for that field. (every field can be from a diffrent table). is it possible to create something like that? if so, how?
Any help will be appritiated,
Thank's In Advance.
Yes, it is possible. Even more, many component libraries have ready to use popup/dialog components, such as RichFaces with <rich:popupPanel> and PrimeFaces with <p:dialog>.
If you do not want to use a component library for some reason, you would need to create a custom component for this which generates basically an absolutely positioned HTML <div> element with a CSS overlay which get shown/hidden by JS on a particular click/action. The HTML/CSS/JS part should be relatively simple if you are familiar with those languages. The JSF part is somewhat hard if you have never created a custom component before, but it should be possible with a composite component as well, so you could also just create one with pure XHTML. The updating/refreshing can just take place by the usual <f:ajax> means.