startsWith autocomplete jsf - autocomplete

Ill just why is it this error apperars when i add this code to my autosuggest
"CANT INSTANTIATE CORE.BEAN"
while(rs.next()) {
String s = rs.getString("name");
if(s.startsWith(text)){
data.add(s);}
here's my xhtml file
<p:autoComplete id="input" value="#{bean.text}" completeMethod="#{bean.complete}" maxResults="11" />
or if im doing it wrong, anyone who could correct me?
Thanks!

Related

Getting the following error " WebDriverError: unknown error: a.tagName.toUpperCase is not a function"

When I tried to enter a text in the below input field I am getting the error although it displayed in the window. The following input element html code is given below. I couldn't understand the reason for the error and unable to find the solution " WebDriverError: unknown error: a.tagName.toUpperCase is not a function"
<input type="text" ng-model="$ctrl.tag.name" ng-if="$ctrl.isSelectedMode" autofocus="autofocus" ng-blur="$ctrl.saveTagName()" name="tagName" ng-keyup="$ctrl.escapeEditing($event)" form-validator="$ctrl.tagName.uniqueError.validator" class="ng-valid ng-valid-uniqueness ng-not-empty ng-dirty ng-valid-parse ng-touched" autocomplete="off" style="">
I have written code in Page Object Model
this.AddTag = function(tagname1,tagname2,tagname3){
let clickAddTag = element(by.xpath("//*[text()='Add Tag']"));
clickAddTag.click();
browser.sleep(2000);
let AddTag = element(by.xpath("//input[#name='tagName']"));
if(AddTag.isPresent()){
AddTag.sendKeys(tagname1);
AddTag.sendKeys(protractor.Key.ENTER);
clickAddTag.click();
AddTag.sendKeys(tagname2);
AddTag.sendKeys(protractor.Key.ENTER);
clickAddTag.click();
AddTag.sendKeys(tagname3);
AddTag.sendKeys(protractor.Key.ENTER);
}
In specs I am calling the method
BidConfiguration.AddTag('tag1','tag2','tag3');
It's because you are trying to uppercase not string but HTML element.
more less stg like that:
element(by.xpath("//*[text()='Add Tag']")).toUpperCase();
You probably want to change text of the element to uppercase.
Try:
element(by.xpath("//*[text()='Add Tag']")).getText().then((elementText) => {
console.log(elementText.toUpperCase());
});
I found the solution
use actions class with sendKeys
browser.actions.click(element).sendKeys('text').perform();

Excepted int for property "maxLength" of sap fiori Input component

Current I am trying to metadata binding xml, following this blog. When I did the maxLength of Input. But I got the following error.
error screenshot
demo service
init model with destination:
initModel: function() {
var sServiceUrl = "/odsrv/V2/Northwind/Northwind.svc/";
var oModel = new OM(sServiceUrl, true);
this.setModel(oModel, "oRefModel");
sap.ui.getCore().setModel(oModel, "oRefModel");
}
xml view:
<content>
<Label text="{oRefModel>/#Category/CategoryName/#type}"/>
<Input maxLength="{oRefModel>/#Category/CategoryName/#maxLength}"/>
</content>
The Label for type works fine if remove Input.
How to solve this problem...
Version with expression binding could be like that
<Input maxLength="{= isNaN(${oRefModel>/#Category/CategoryName/#maxLength}) ? 0 : parseInt(${oRefModel>/#Category/CategoryName/#maxLength})" />
typeof check is needed cause at the start of binding process value of property probably is 'NaN' and it gives an error and whole process will stop.
If you can improve that version please do :)
<Input maxLength="{parts:[{path:'oRefModel>/#Category/CategoryName/#maxLength'}],formatter: 'your.formatter.toNum' }" />
Formatter Code
toNum : function(maxlen){
return parseInt(maxlen);;
}
Converting string to integer is the key
Even shorter and without writing a custom formatter function: Use the built-in parseInt function.
<Input
maxLength="{
path: 'oRefModel>/#Category/CategoryName/#maxLength',
formatter: 'parseInt'
}" />
For some reasons expression binding does not work, maybe someone could tell me why:
<Input maxLength="{= parseInt(${oRefModel>/#Category/CategoryName/#maxLength}) }" />

Extracting data-reactid with DOM

im trying to scrap a website using dom, but im unable to extract this:
<h1 data-reactid="218">
some info
some info
</h1>
i've been trying this query, but it doesnt work
$allClass = $xpath->query("//h1[#data-reactid='218'");
foreach ($allClass as $urs)
{
foreach ($urs->attributes as $att2)
{
print_r($att2->value);
}
}
Could anyone help me please?
You are missing a closing bracket ] in your xpath expressions.
Replace this line:
$allClass = $xpath->query("//h1[#data-reactid='218'");
With this line:
$allClass = $xpath->query("//h1[#data-reactid='218']");
That will give you:
218

what error is in the code snippet below?

I have the following jsp code which uses struts tag:
<input type = "radio"
id = "<s:property value="name"/>"
name = "<s:property value="name"/>"
value = "<s:property value="value"/>"
<s:if test="fieldValue==null">
<s:if test="defaultOption==true">
checked="checked"
</s:if>
</s:if>
<s:else>
<s:if test="value==fieldValue">
checked="checked"
</s:if>
</s:else>
/>
Eclipse says that:
Start tag (input) not closed properly, expected >.
But I cannot find where is the error. Please help.
It is probably an eclipse bug because with Netbeans there is no error
if you dont want to see the error with Eclipse (and in that case only) :
in the first if, put test like that :
fieldValue==null && defaultOption==true
and get rid of the internal if
it should be the same
PS : try to find a way to use s:radio maybe
Eclipse complains because it does not accept tags (for example <s:if>) inside input tag, you can deactivate JSP validation as suggested in comments .
Go to project properties and uncheck JSP Content Validator, then clean your project
If you don't want to disable validation, here is a suggested solution:
<s:if test="fieldValue==null">
<s:if test="defaultOption==true">
<input type = "radio" id = "<s:property value="name"/>" name = "<s:property value="name"/>" value = "<s:property value="value"/>" checked="checked" />
</s:if>
</s:if>
<s:else>
<s:if test="value==fieldValue">
<input type = "radio" id = "<s:property value="name"/>" name = "<s:property value="name"/>" value = "<s:property value="value"/>" checked="checked" />
</s:if>
</s:else>
Just as a note, your JSP code give same result(I guess it's just for illustration :) ).

downloading form tag into csv file format

I need some help or guide on how to download a form into a CSV file. What I'm trying to do here is :
<form>
<select name="mydropdown">
<option value="Chicken">Fresh Milk</option>
<option value="Apple">Old Cheese</option>
<option value="Bread">Hot Bread</option>
</select>
</form>
<input type=button>
The GSP should be some what look like this and when the csv file is being downloaded, I'm not sure what the controller needs and the result should be one of the values in the options that is being selected and display it as text in the file. By the way I'm using grails. So is there anyone out there can help me with this? I've been researching on it and there isn't any result on this.
Thank you guys so much :)
You can use OpenCSV to do the work.
Define the dependency
dependencies {
...
compile('net.sf.opencsv:opencsv:2.0')
...
}
Create the action
def export() {
ByteArrayOutputStream output = new ByteArrayOutputStream()
char separator = ';'
CSVWriter writer = new CSVWriter(new OutputStreamWriter(output), separator);
def line = [params.mydropdown]
writer.writeNext(line as String[])
//use writeNext as many times as needed
writer.close()
byte[] bytes = output.toByteArray()
//needed to force download
response.setContentType("text/csv")
response.setContentLength(bytes.length)
response.setHeader("Content-Disposition", "attachment; filename=mycsv.csv")
response.outputStream << bytes
}
Change your form to go to export
<g:form action="export">
...
</g:form>