I have a jsff page.
In this, I define a <af:form id="f1"></af:form>
How do I add parameter to action attribute in this form?
I used <f:param ... /> tag inner this form:
<af:form id="f1">
<f:param value="#{param.id}" name="id"/>
...
</af:form>
but it's not working.
If you want to pass a parameter. Do that in the commandButton/commandLink. Or else you could pass a attribute to the form.
Passing a parameter
<af:commandLink text="click here"
action="#{testbean.buttonClicked}" >
<f:param name="et1" value="etc"/>
</af:commandLink>
Access it In the Bean
FacesContext facesContext= FacesContext.getCurrentInstance();
Map requestMap=facesContext.getExternalContext().getRequestParameterMap();
Or
Passing an Attribute
<af:form id="f1" binding="#{testbean.form}">
<f:attribute name="et1" value="etc"/>
In the Bean
In Action Method
String value2=(String)form.getAttributes().get("et1");
Or best yet use
af:setPropertyListener
In the command component
<af:commandLink text="click here"
action="#{testbean.buttonClicked}" >
<af:setPropertyListener type="action" from="etc" to="#{et1}"/>
</af:commandLink>
In the Bean on action method
String value3=(String)evaluateEL("#{et1}");
put a button or link or ... in your form and use:
<af:setActionListener from="value" to="#{...Scope.yourParam}"/>
"..." can be SessionScope,pageFlowScope,etc
Related
I am using Emberjs Textarea which has 2 way binding with the #value attribute.
The data I am passing into the value is from an argument and therefore needs to be return from a getter before I can use it in the template.
My question is how do I use 2 way binding with a getter. I keep on getting error messages stating that Cannot set property inputText of #<InputComponent> which has only a getter
I have tried to use {{mut}} and tried to create a setter for the getter but nothing has worked.
The post requests actually work but I still get those annoying errors in the console.
// Component JS
get inputText() {
return this.args.text;
}
// Component Template
<Textarea #value={{this.inputText}} #focusOut={{this.postRequest}} />
Looks like setting the args value directly in the template will work.
<Textarea #value={{#inputText}} #focusOut={{this.postRequest}} />
I've defined an input field in one of my Handlebars template as follows:
<input {{bind-attr value=stratName}}>
I didn't want to use this:
{{input value=stratName}}
because I want to run a validation function against user input before the new value is copyied to the model.
What's the easiest way to attach a validation function, triggered on focusOut, on the input tag? I also want to keep the user from leaving the field until a valid input is detected?
You could use https://github.com/dockyard/ember-validations and attach the validation to the field, and on blur execute the validation, complaining or refocusing if the validation fails.
I'm newbie in Orbeon xforms, so I ask my questions here. I have REST webservice with some address (method GET) and I want to call him and the result should be provide to metadata of my form:
<!-- Main instance -->
<xforms:instance id="fr-form-instance">
<form>
<section-meta>
<resultOfMyRestWebservice/>
I've tried to follow this tutorial http://wiki.orbeon.com/forms/how-to/logic/load-initial-form-data (pull solution) but I don't know how I can put the result of rest in the marker: resultOfMyRestWebservice, and where I have to put the submission code:
<xforms:submission
id="load-data-submission"
method="get" serialization="none"
resource="addressOfMyRestWS/{xxforms:get-request-parameter('myParam')}"
replace="?" instance="?"/>
regards
If I were you I would use a temporary run-time instance to hold the results of your REST call and then use setvalue to populate your persisting instance.
The following example works if you define the structure of your meta-data in your model, so you can use setvalue to populate. Otherwise you can use insert.
Ie. In your xforms:model define:
<!-- Run-time instance to hold Service response -->
<xforms:instance id="fr-service-response-instance" xxforms:exclude-result-prefixes="#all">
<response/>
</xforms:instance>
Define your submission to replace this response instance:
<xforms:submission id="load-data-submission" method="get"
serialization="none" mediatype="application/xml"
resource="addressOfMyRestWS/{xxforms:get-request-parameter('myParam')}"
replace="instance" instance="fr-service-response-instance"/>
And then create an action to call the submission and populate your instance:
<!-- Populate Data
uses Load Data Submission
runs on form load -->
<xforms:action id="populate-data-binding">
<xforms:action ev:event="xforms-ready" ev:observer="fr-form-model" if="true()">
<xforms:send submission="load-data-submission"/>
</xforms:action>
<!-- Populate resultOfMyRestWebservice control with pathToResults value
following successful submission -->
<xforms:action ev:event="xforms-submit-done" ev:observer="load-data-submission"
context="instance('fr-service-response-instance')">
<xforms:action>
<xf:var name="control-name" value="'resultOfMyRestWebservice'" as="xs:string"/>
<xf:var name="control-value" value="/pathToResults" as="xs:string"/>
<xforms:setvalue ref="instance('fr-form-instance')/*/*[name() = $control-name]"
value="$control-value"/>
</xforms:action>
</xforms:action>
</xforms:action>
Note pathToResults is the xpath to the value you want from the results.
I do everything like in mentioned tutorial: http://wiki.orbeon.com/forms/how-to/logic/load-initial-form-data I mean:
....
<xf:model id="fr-form-model" xxf:expose-xpath-types="true">
<!-- User in which user data is collected -->
<xf:instance id="user-data">
<registration>
<first-name/>
<last-name/>
</registration>
</xf:instance>
<!-- Load initial data from a service -->
<xf:send ev:event="xforms-model-construct-done" submission="load-data-submission"/>
<xf:submission id="load-data-submission" method="get" serialization="none"
resource="http://github.com/orbeon/orbeon-forms/raw/master/src/resources/apps/xforms-sandbox/samples/howto/load-initial-form-data-pull-instance.xml"
replace="instance"
instance="user-data"/>
<!-- Main instance -->
<xf:instance id="fr-form-instance">
<form>
<name/>
....
....
<fr:body xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:dataModel="java:org.orbeon.oxf.fb.DataModel"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:p="http://www.orbeon.com/oxf/pipeline">
....
<xforms:action ev:event="xforms-enabled">
<xforms:setvalue ref="xxf:instance('fr-form-instance')/name"
value="xxf:instance('user-data')/first-name"/>
</xforms:action>
</fr:body>
....
I want to get xml from link (http://github.com/orbeon/orbeon-forms/raw/master/src/resources/apps/xforms-sandbox/samples/howto/load-initial-form-data-pull-instance.xml), put in to the 'user-data' instance and then get the first-name and put to the 'name' marker in the 'fr-form-instance'. Unfortunately it does not working, I mean setvalue not working, because when I change 'user-instance' like that:
<xf:instance id="user-data">
<registration>
<first-name>SomeName</first-name>
<last-name/>
</registration>
</xf:instance>
it working, and the final xml look like:
....
<name>SomeName</name>
....
I really haven't idea why it doesn't working.
regards
///
Now I see that my problem may be reduced to:
It works:
<xforms:instance id="user-data" src="http://example.org/service/load-initial-form-data-pull-instance"/>
And it does not work:
<xforms:send ev:event="xforms-model-construct-done" submission="load-data-submission"/>
<xforms:submission id="load-data-submission"
method="get" serialization="none"
resource="http://example.org/service/load-initial-form-data-pull-instance"
replace="instance" instance="user-data"/>
I have to use second way, because I have to pass some parameter to resource (resource="http.../{xxforms:get-request-parameter('myParam')}")
I am developing a Joomla 2.5 component. So I'm using Hello world example component for reference... In the edit view of the admin back end
<?php foreach($this->form->getFieldset('details') as $field): ?> <div>
<?php echo $field->label; echo $field->input;?> </div>
where the array $this->form->getFieldset('details') is stored.. and how to add new fields to the form that will store the data to another database table. where to change the fielda of the forms.
If you need to add more fields in your form then you can add new field in to the helloworld.xml browse to the following file on to
administrator->components->com_helloworld->models->forms->helloworld.xml
Open this file you will find the number of fields are listed over there you can add your own field by copy any of the field and rename it as you want.
You can also refer this link : J2.5:Developing a MVC Component/Adding backend actions
For example you want to add description field on to your form then you just need to add this line between the fieldset tag.
<field
name="description"
type="text"
label="COM_HELLOWORLD_HELLOWORLD_DESCRIPTION_LABEL"
description="COM_HELLOWORLD_HELLOWORLD_DESCRIPTION_DESC"
size="40"
class="inputbox"
default=""
/>
I would prefer you first read full tutorial of how to create MVC component for Joomla.Then you would be able to know how it works. Here the link :
J2.5:Developing a MVC Component/Developing a Basic Component
You may also use different form field type : Form field
I have a selectOneMenu item with some products. Some of them are unavailable so after you click on it the button "Add" should be disabled and some message should appear that "Sorry the product you chose is currently unavailable". I have no idea how to achieve that. Tried listeners, ajax and still nothing.
This is one of many versions of my JSF Page:
<h:form>
<h:selectOneMenu value="#{productBean.productName}">
<f:selectItems id ="other" value="#{productBean.other}" var="other" itemValue="#{ordersBean.productName}" itemLabel="#{other.name}" />
<f:ajax listener="#{productBean.valueChanged}" />
</h:selectOneMenu>
<h:commandButton value ="Dodaj do zamówienia" rendered="#{productBean.available}"/>
<h:outputLabel id="orderSummary"/>
</h:form>
Beans are rather standard. I just need a clue how to do that and probably I will be able to do it myself.
Thanks in advance.
Here's one of the ways:
In your AJAX listener you could check if a product is available and set up bean field accordingly, or add a message for a component.
Introduce a component in your view that'll hold the message to the user, for example with the #{bean.available ? '' : 'Sorry, out of stock'} value, or enclose it within a <h:panelGroup> and let that component have a rendered attribute, or attach <h:message>/<h:messages> somewhere in your view.
Specify id of the message holder to be rendered within render attribute of <f:ajax> tag.