Search Results

Search found 7914 results on 317 pages for 'valid xhtml'.

Page 58/317 | < Previous Page | 54 55 56 57 58 59 60 61 62 63 64 65  | Next Page >

  • Problem with errorPlacement in validator plugin jQuery

    - by novellino
    Hello, I am using the validator plugin of jQuery. By default the error label is added below my form. I want to add it above my form. So what I am doing is adding the code below in the validate(): errorPlacement: function (error, element) { error.insertBefore('form#emailForm'); } The problem is that the error label now is added a lot of times above the form, in every click. So I have something like this: Enter valid email.Enter valid email.Enter valid email. Does anyone know what's wrong with it? Thanks in advance!

    Read the article

  • count of distinct acyclic paths from A[a,b] to A[c,d]?

    - by Sorush Rabiee
    I'm writing a sokoban solver for fun and practice, it uses a simple algorithm (something like BFS with a bit of difference). now i want to estimate its running time ( O and omega). but need to know how to calculate count of acyclic paths from a vertex to another in a network. actually I want an expression that calculates count of valid paths, between two vertices of a m*n matrix of vertices. a valid path: visits each vertex 0 or one times. have no circuits for example this is a valid path: but this is not: What is needed is a method to find count of all acyclic paths between the two vertices a and b. comments on solving methods and tricks are welcomed.

    Read the article

  • Can you restrict entering invalid keystrokes with jquery ui autocomplete combobox

    - by oo
    when using the jquery ui autocomplete combobox, i would thought there would be an option to force only valid key entry based on the list. Is there anyway to not allow invalid keys so you can only enter valid items in the list? also, is there a way to set a default value of the combobox. if my list has (csharp, java, python) i can start typing "abcds . ." and it lets me type it in. I want only valid entries to be allowed.

    Read the article

  • Defining functions and if statement problems

    - by David Fairbairn
    I'm having a problem with two functions and an if statement. I'm being told the functions go and postcodeChange are not defined. I'm also being told flag is an unexpected identifier at if flag == 1. Any idea where I am going wrong? Thank you. function postcodeChange(){ document.getElementById("goButton").onclick = distanceCheck; } function distanceCheck(){ var distance = document.getElementById("distance").value var patt1=new RegExp("^[0-9]+(\.[0-9]{1})?$"); var out = patt1.exec(distance); if (out == null) { //distance is not a valid number document.getElementById("distanceFlag").value = 1 } else { //distance is valid number document.getElementById("distanceFlag").value = 0 } function go(){ var flag = document.getElementById("distanceFlag").value if flag == 1 { alert("Distance is not valid- enter a number with no more than one decimal point"); } else{ popSubmit('#fa Care Provider Search Go','','0'); } }

    Read the article

  • Validate Unicode String and Escape if Unicode is Invalid (C/C++)

    - by vy32
    I have a program that reads arbitrary data from a file system and outputs results in Unicode. The problem I am having is that sometimes filenames are valid Unicode and sometimes they aren't. So I want a function that can validate a string (in C or C++) and tell me if it is a valid UTF-8 encoding. If it is not, I want to have the invalid characters escaped so that it will be a valid UTF-8 encoding. This is different than escaping for XML --- I need to do that also. But first I need to be sure that the Unicode is right. I've seen some code from which I could hack this, but I would rather use some working code if it exists.

    Read the article

  • Can I pop up alert in javascript using php.

    - by Shantanu Gupta
    I want to trigger javascript alert using PHP. Is it possible I want to use it in head section, for displaying it at load time. <head> <?php $valid="valid"; if(!isset($valid)) echo "<script type=\"text/javascript\"> alert('Hi');</script>"; ?> </head> EDIT i want to display javascript alert() at load time after checking existance of session

    Read the article

  • word ladder in python

    - by user365523
    I'm trying to create a word ladder program in python. I'd like to generate words that are similar to a given word. In c++ or java, I would go through each valid index in the original string, and replace it with each letter in the english alphabet, and see if the result is a valid word. for example (pseudocode) for (int i = 0; i < word.length(); i++) { for (every character c in the alphabet) { change the letter of word at index i to be c. if the result is a valid word, store it in a list of similar words } } . However, this doesn't seem like a very "python" way of doing things. How would I approach this problem in python?

    Read the article

  • jQuery + Validation plugin: add/remove class to/from element's parent

    - by FreekOne
    Hi guys, I'm working with the jQuery Validation plugin and I wrote the following code which adds a class to the element's parent if not valid (as well as inserting the actual error message at a particular location within the parent): errorPlacement: function(error, element) { element.parent().addClass('error'); error.insertBefore(element.parent().children("br")); } This works, however, if a field's content is corrected and becomes valid, the class obviously doesn't get removed from its parent (actually, neither does the error element, instead it just gets a display: none; CSS property). How can I check if an element becomes valid and remove its parent class if so ? Any help would be much appreciated, thank you !

    Read the article

  • PHP validating integers

    - by Mikk
    Hi, I was wondering, what would be the best way to validate an integer. I'd like this to work with strings as well, so I could to something like (string)+00003 - (int)3 (valid) (string)-027 - (int)-27 (valid) (int)33 - (int)33 (valid) (string)'33a' - (FALSE) (invalid) That is what i've go so far: function parseInt($int){ //If $int already is integer, return it if(is_int($int)){return $int;} //If not, convert it to string $int=(string)$int; //If we have '+' or '-' at the beginning of the string, remove them $validate = ($int[0] === '-' || $int[0] === '+')?substr($int, 1):$int; //If $validate matches pattern 0-9 convert $int to integer and return it //otherwise return false return preg_match('/^[0-9]+$/', $validate)?(int)$int:FALSE; } As far as I tested, this function works, but it looks like a clumsy workaround. Is there any better way to write this kind of function. I've also tried filter_var($foo, FILTER_VALIDATE_INT); but it won't accept values like '0003', '-0' etc.

    Read the article

  • How to continue after exception occurred in C#

    - by Manisha
    static string SomeMethodThatMightThrow(string s) { if (s[4] == 'C') throw new InvalidOperationException(); return @"C:\newFolder\" + s; } static void Main(string[] args) { string[] files = { "fileA.txt", "B.txC", "fileC.txt","fileD.txt" }; var exceptionDemoQuery = from file in files let n = SomeMethodThatMightThrow(file) select n; try { foreach (var item in exceptionDemoQuery) { Console.WriteLine("Processing {0}", item); } } catch (InvalidOperationException e) { Console.WriteLine(e.Message); } Console.WriteLine("Press any key to exit"); Console.ReadKey(); } Output is Processing C:\newFolder\fileA.txt Operation is not valid due to the current state of the object. But i need the Output as: Processing C:\newFolder\fileA.txt Operation is not valid due to the current state of the object. Operation is not valid due to the current state of the object. Processing C:\newFolder\fileD.txt Please help in this.............

    Read the article

  • Cannot connect via HTTPS in Java app on MacOSX (Certificate validation issue)

    - by johnnyx
    I have a java application that connects to a webservice over https. The domain where i host the webservice has a valid Goddaddy issued SSL certificate. The application works fine on Windows but on MacOSx i receive the following exception when attempting to connect to the webservice via https. sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target I've tested it on two machines running Mac OS X 10.7.2 with the latest java runtime updates. I understand this is usually a problem with self signed certificates that need to be added manually, but i have a valid Godaddy issued certificate. In webbrowsers (safari & firefox) on mac os the certificate is recognized and seems ok. I even tried adding the certificate to the key chain manually like in the gase of a self signed one but to no result.

    Read the article

  • What is the MVC version of this code?

    - by Ian Boyd
    i'm trying to wrap my head around how to enterprise up my code: taking a simple routine and splitting it up into 5 or 6 methods in 3 or 4 classes. i quickly came up three simple examples of code how i currently write it. Could someone please convert these into an MVC/MVP obfuscated version? Example 1: The last name is mandatory. Color the text box red if nothing is entered. Color it green if stuff is entered: private void txtLastname_TextChanged(object sender, EventArgs e) { //Lastname mandatory. //Color pinkish if nothing entered. Greenish if entered. if (txtLastname.Text.Trim() == "") { //Lastname is required, color pinkish txtLastname.BackColor = ControlBad; } else { //Lastname entered, remove the coloring txtLastname.BackColor = ControlGood; } } Example 2: The first name is optional, but try to get it. We'll add a bluish tint to this "try to get" field: private void txtFirstname_TextChanged(object sender, EventArgs e) { //Firstname can be blank. //Hint them that they should *try* to get it with a bluish color. //If they do enter stuff: it better be not all spaces. if (txtFirstname.Text == "") { //Nothing there, hint it blue txtFirstname.BackColor = ControlRequired; } else if (txtFirstname.Text.Trim() == "") { //They entered spaces - bad user! txtFirstname.BackColor = ControlBad; } else { //Entered stuff, remove coloring txtFirstname.BackColor = SystemColors.Window; } } Example 3 The age is totally optional. If an age is entered, it better be valid: private void txtAge_TextChanged(object sender, EventArgs e) { //Age is optional, but if entered it better be valid int nAge = 0; if (Int32.TryParse(txtAge.Text, out nAge)) { //Valid integer entered if (nAge < 0) { //Negative age? i don't think so txtAge.BackColor = ControlBad; } else { //Valid age entered, remove coloring txtAge.BackColor = SystemColors.Window; } } else { //Whatever is in there: it's *not* a valid integer, if (txtAge.Text == "") { //Blank is okay txtAge.BackColor = SystemColors.Window; } else { //Not a valid age, bad user txtAge.BackColor = ControlBad; } } } Every time i see MVC code, it looks almost like random splitting of code into different methods, classes, and files. i've not been able to determine a reason or pattern to their madness. Without any understanding of they why it's being one some way, it makes no sense. And using the words model, view, controller and presenter, like i'm supposed to know what that means, doesn't help. The model is your data. The view shows data on screen. The controller is used to carry out the users actions And oranges taste orangy. Here's my attempt at splitting things up in order to make the code more difficult to follow. Is this anywhere close to MVC? private void txtFirstname_TextChanged(object sender, EventArgs e) { FirstnameTextChangedHandler(sender, e); } private void FirstnameTextChangedHandler(sender, e) { string firstname = GetFirstname(); Color firstnameTextBoxColor = GetFirstnameTextBoxColor(firstname); SetFirstNameTextBoxColor(firstnameTextBoxColor); } private string GetFirstname() { return txtFirstname.Text; } private Color GetFirstnameTextBoxColor(string firstname) { //Firstname can be blank. //Hint them that they should *try* to get it with a bluish color. //If they do enter stuff: it better be not all spaces. if (firstname == "") { //Nothing there, hint it blue return GetControlRequiredColor(); } else if (firstname.Trim() == "") { //They entered spaces - bad user! return GetControlBadColor(); } else { //Entered stuff, remove coloring return GetControlDefaultColor(); } } private Color GetControlRequiredColor() { return ControlRequired; } private Color GetControlBadColor() { return ControlBad; } private Color GetControlGoodColor() { return ControlGood; } //am i doin it rite i've obfuscated the code, but it's still altogether. The next step in the MVC obfuscation, i gather, is to hide the code in 3 or 4 different files. It's that next step that i don't understand. What is the logical separation of which functions are moved into what other classes? Can someone translate my 3 simple examples above into full fledged MVC obfuscation? Edit: Not ASP/ASP.NET/Online. Pretend it's on a desktop, handheld, surface, kiosk. And pretend it's language agnostic.

    Read the article

  • Regular Expression; Find whether a line contains any word with more than X characters.

    - by Simpsoid
    Hi, I am trying to use a Validator on a ASP.NET site and need to find whether the Street Address textbox contains a valid entry. Entries with words that are longer than X characters (in this case 25, with no punctuation or spaces) will cause the HTML on a printed A4 page to not wrap properly and therefore not to confrom to certain sizes correctly pushing the margins off. For a street address I want to match that something like "201 Long Road" is valid but "235 ReallyLongAndNarrowWindingRoadBesideTheRiver Street" is invalid. Using a Microsoft .Net Regular Expression Validator I need to know what the RegEx pattern might be. I think if it does find a match the Validator will fire correctly however if there is no match the Validator won't fire and the Update button (in this case) won't fire. Since Street addresses can contain Capital Letters and numbers etc. it will need to accomodate for that and also Spaces, Commas, Semi-Colons and Colons and Hyphens are valid characters too. Any help would be greatly appreciated as I am really stuck with this problem. Thanks, David

    Read the article

  • HTML tag closes when inside a condition

    - by Malharhak
    I'm having a little problem with jade. Here is the following code : each user in users - if (user.valid == 1) tr(style="color:green;") - else tr(style="color:red;") td = user.mail td = user.lastIp td = user.token td = user.valid My problem is that the tds are created only in the else case. if the if (user.valid == 1) is true, then it creates an empty tr. Is there a way I can create my tr with this condition, and then only fill them ? Thanks :)

    Read the article

  • how to write regular expression to validate a string using regex in C#

    - by Charu
    I need to validate a user input based on condition. i wrote a regular expression to do so, but it's failing not sure why. Can somebody point where i am making mistake? Regex AccuracyCodeHexRegex = new Regex(@"^[PTQA]((0|8)[01234567]){2}$"); This is what i am trying to validate(If the string is a subset of these strings then it is valid): Phh, Thh, Qhh, Ahh where 'h' is a hex digit in the set {00, 80, 01, 81, 02, 82, 03, 83, 04, 84, 05, 85, 06, 86, 07, 87} Ex: P00 is valid P20 is not valid

    Read the article

  • Why is this jquery dialog window not displaying?

    - by user338413
    I've got a form that is using jquery validation. When the user clicks the submit button, I've got some jquery that intercepts the submit and should display a dialog window asking the user to verify the information they entered on the form. This dialog window should only display if the form has validated. Here is my code: $('#form').submit(function(){ fillVerificationDialog(); /* This loads up the dialog with form data */ if (('#form').valid()){ $('verification_dialog').dialog('open'); return false; } }); My dialog window is not displaying. It just submits the form. And I've verified that the form is valid by using an alert that checks the value of $('#form').valid() If I remove the if statement and just have the line that opens the dialog, the dialog displays. However, it will display even if the form has errors which is what I'm trying to prevent.

    Read the article

  • Check result of ASP.Net validator clientside

    - by Steffen
    I know the built-in ASP.Net validators come with a client-side framework, however I've been unable to find anything that lets me check a single validator for it's Valid state. I expect it to be possible though, so I hope someone in here knows how to do it :-) The validator in question is a RegularExpressionValidator, which I use to determine whether an e-mail address is valid or not. Here's some brief code: <script> function CheckForExistingEmail() { Page_ClientValidate(); // Ensure client validation if (revEmail.IsValid) // pseudo code! { // Perform server side lookup in DB for whether the e-mail exists. } } </script> <asp:TextBox runat="server" id="tbEmail" onblur="CheckForExistingEmail();" /> <asp:RegularExpressionValidator id="revEmail" runat="server" ControlToValidate="tbEmail" ErrorMessage="Not a valid e-mail address" ValidationExpression="([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})" />

    Read the article

  • asp.net web application - server side canceling Submit PostBackUrl if not(!) Page.IsValid

    - by Brent
    Thanks for any help I have a web application, and the submit uses the PostBackUrl to display data if the form is valid. I need to use different (server side) validation groups, depending on what radiobutton is selected. That is, manually call Page.Validate('ValidationGroupA'). The validation itself is working fine, in terms of Page.IsValid correctly assigned true or false. however, if the page is not valid, the page redirects to the page specified by PostBackUrl on the submit button, where the page is found not to be valid, and the client redirected back with: if (!PreviousPage.IsValid){Response.Redirect("DataEntryPage.aspx");}) However, by getting to here and back again, all form data is lost, and the relevant validation controls and summaries are not displayed. is there an equivalent of javascripts evt.preventDefault() or some other way, once it is detected validation has failed after a manual call to Page.Validate to post the form back with appropriate validation errors displayed? Thank you.

    Read the article

  • mod_rewrite not working?

    - by Sean Kimball
    I have a bunch of non-existent urls that need to be redirected to new ones, though they are not working... mod_rewrite does work and is enabled, I'm wondering if the redirect URL has to actually exist in order for a redirect ot work. Here is what I have: Redirect 301 /cgi-bin/commerce.cgi?display=action&emptyoverride=yes&template=Assets/XHTML/Advantage.html http://domain.com/the-bag-to-nature-advantage.html UPDATE this is the request that comes in [indexed in google!] http://domain.com//cgi-bin/commerce.cgi?display=action&emptyoverride=yes&template=Assets/XHTML/Advantage.html this is where it needs to go: http://domain.com/the-bag-to-nature-advantage.html

    Read the article

  • Page won't load on IE9 unless developer tools are started first

    - by RoyHB
    One of my pages (with very extensive javascript) won't load on IE9. It loads ok in Mozilla, Chrome, Safari and Opera. If IE9 Developer tools are running it loads fine. If I load IE9, load the developer tools (F12) then kill the developer tools it still loads fine. If developer tools are running then sometimes (but not always) the first message in the console is: HTML1113: Document mode restart from Quirks to IE9 Standards Doctype is: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> If I change doctype to and remove the xmlns nothing changes. I'm stumped. Any suggestions appreciated.

    Read the article

  • What is the technique used to make my IIS 7 serve all pages with an injected iframe

    - by Andre Carlucci
    Since my previous question was closed without an answer, I'm changing it a bit and asking again. All my pages are being served with an malicious iframe injected just before the html tag. The code looks like this: <iframe src= http://117.21.247.171:700/1.htm width=0 height=0></iframe> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="pt-BR"> ... Firstly I thought it could be something related with wordpress, but my asp.net sites are also infected and even if I create a static html file with nothing inside, the iframe is injected. I'm using a Windows Server 2008 R2 Standard with IIS7.5 7600. Anyone knows how to do this in IIS?

    Read the article

  • ASP.NET resseting SessionID cookie when cookie expiration date is set

    - by Sergej Andrejev
    I have two pages: Default.aspx and WebForm1.aspx. One of these pages stores a session variable which works fine until I add code which ads expiration date to SessionID cookie. What happens is: Open default.aspx Set-Cookie ASP.NET_SessionId=14jhsdfq23jkh13jkh12k1; expires=Fri, 19-Mar-2010 07:31:47 GMT; path=/ Click on link to open WebForm1.aspx No cookies set Click on link to open Default.aspx (Cookie is reset) Set-Cookie ASP.NET_SessionId=; expires=Fri, 19-Mar-2010 07:31:47 GMT; path=/ So the question would be how should I set SessionID cookie expiration date correctly? Default.aspx.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication1 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { lnk.Click += new EventHandler(lnk_Click); Session["t"] = Guid.NewGuid(); Response.Cookies["ASP.NET_SessionId"].Expires = DateTime.Now.AddDays(2); } void lnk_Click(object sender, EventArgs e) { Response.Redirect("WebForm1.aspx"); } } } Default.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:LinkButton runat="server" ID="lnk" Text=">>>" /> </div> </form> </body> </html> WebForm1.aspx.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication1 { public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { lnk.Click += new EventHandler(lnk_Click); } void lnk_Click(object sender, EventArgs e) { Response.Redirect("Default.aspx"); } } } WebForm1.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:LinkButton runat="server" ID="lnk" Text=">>>" /> </div> </form> </body> </html>

    Read the article

  • HTML and PHP simple contact form.

    - by user317128
    I tried to make a simple contact form via HTML and PHP but the form doesnt seem to submit. it stays on the HTML page and doesnt post to the php form. would love someone to look over the code, thanks in advanced. simple_form.html cdoe <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Simple Feedback Form</title> </head> <body> <form action="send_simpleform.php" method="post"> <p>Your name<br /> <input name="sender_name" type="text" size="30" /></p> <p>Email<br /> <input name="sender_email" type="text" size="30" /></p> <p>Message<br /> <textarea name="message" cols="30" rows="5"></textarea></p> <input name="submit" type="button" value="Send This Form" /> </form> </body> </html> send_simpleform.php code <? if (($_POST[sender_name] == "") || ($_POST[sender_email] == "") || ($_POST[message] == "") { header("Location: simple_form.php"); exit; } $msg = "Email sent from wwwsite\n"; $msg .= "Sender's Name:\t $_POST[senders_name]\n"; $msg .= "Sender's E-mail:\t $_POST[senders_email]\n"; $msg .= "Sender's Message:\t $_POST[message]\n"; $to = "[email protected]"; $subject = "Website feedback message"; $mailheaders = "From: My web site <www.testwebsite.com>\n"; $mailherders .= "Reply to: $_POST[sender_email]\n"; $mail($to, $subject, $msg, $mailheaders); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Simple Feedback Form Sent</title> </head> <body> <h1>The following email has been sent</h1> <p>Your Name:<br /> <? echo "$_POST[sender_name]"; ?> <p>Your Email Adress:<br /> <? echo "$_POST[sender_email]"; ?> <p>Message:<br /> <? echo "$_POST[message]"; ?> </p> </body> </html>

    Read the article

  • Why do I get error "prefix [..] is not defined" when I try to use my jsf custom tag?

    - by Roman
    I created a jsf custom tag (I'm not sure that it's correct, I could miss something easily, so I attached code below). Now I'm trying to use this tag but I get an error: error on line 28 at column 49: Namespace prefix gc on ganttchart is not defined So, here is the xhtml-page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:gc="http://myganttchart.org"> <body> <ui:composition template="/masterpage.xhtml"> <ui:define name="title">Gantt chart test</ui:define> <ui:define name="content"> <f:view> <gc:ganttchart width="300" height="100" rendered="true"/> ... </f:view> </ui:define> </ui:composition> </body> </html> And here is tld-file (it's placed in WEB-INF/): <taglib xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1"> <tlib-version> 1.0 </tlib-version> <short-name> oext </short-name> <uri> http://myganttchart.org </uri> <tag> <name>ganttchart</name> <tag-class>usermanagement.support.ganttchart.GanttChartTag</tag-class> <body-content>empty</body-content> <attribute> <name>binding</name> <deferred-value> <type>javax.faces.component.UIComponent</type> </deferred-value> </attribute> ... </tag> </tablib> Here is a part of tag-class code: public class GanttChartTag extends UIComponentELTag { private ValueExpression width; private ValueExpression height; private ValueExpression styleClass; public String getComponentType () { return "org.myganttchart"; } public String getRendererType () { return null; } ... } Correspondent block from faces-config: <component> <component-type>org.myganttchart</component-type> <component-class>usermanagement.support.ganttchart.UIGanttChart</component-class> </component> And the last part if UIGanttChart: public class UIGanttChart extends UIOutput { public UIGanttChart() { setRendererType (null); } //some test code public void encodeBegin(FacesContext context) throws IOException { ResponseWriter writer = context.getResponseWriter (); writer.startElement("img", this); writer.writeAttribute("src", "no-img", "source"); writer.writeAttribute("width", getAttributes ().get ("width"), "width"); writer.writeAttribute("height", getAttributes ().get ("height"), "height"); writer.writeAttribute("class", ".someclass", "styleClass"); writer.endElement("img"); } } So, what did I miss?

    Read the article

  • Losing sessions on GlassFish

    - by synti
    I have a web application that logs users in a @SessionScoped managed bean. It's all the basic stuff, pretty much like this: users logs in using regular http form and gets redirect to user area (wich is protected using a filter). But if any resource on that area is accessed, the request somehow uses a new session, wich has no managed bean, no user, and the filter does his job, redirecting him to login page. Here's the login form: <h:form> <h:outputLabel for="email" value="Email "/> <p:inputText id="email" size="30" value="#{loginManager.email}"/> <h:outputLabel for="password" value="Password "/> <p:password id="password" size="12" value="#{loginManager.password}"/> <p:commandButton value="Login" action="#{loginManager.login()}"/> </h:form> The loginManager managed bean: @ManagedBean @SessionScoped public class LoginManager implements Serializable { @EJB private UserService userService; private User user; private String email; private String password; public String login() { user = userService.findBy(email, password); if (user == null) { // FacesMessage stuff } else { return "/user/welcome.xhtml?faces-redirect=true"; } } public String logout() { FacesContext.getCurrentInstance().getExternalContext().invalidateSession(); return "/index.xhtml?faces-redirect=true"; } // Getters, setters (no setter for user) and serialVersionUID And then comes the filter that protects the user area: @WebFilter(urlPatterns="/user/*", displayName="UserFilter") public class UserFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpSession session = ((HttpServletRequest)request).getSession(false); LoginManager loginManager = (LoginManager) session.getAttribute("loginManager"); if (loginManager == null || !loginManager.hasUser()) { HttpServletResponse resp = (HttpServletResponse) response; resp.sendRedirect("index.xhtml"); } final User user = loginManager.getUser(); if (user.isValid()) { chain.doFilter(request, response); } else { HttpServletResponse resp = (HttpServletResponse) response; resp.sendRedirect("index.xhtml"); } } The UserService is just a stateless EJB that handles persistence. Part of the JSF for user area: <h:form> <p:panelMenu> <p:submenu label="Items"> <p:menuitem value="Add item" action="#{userItens.addItems}" ajax="false"/> <p:menuitem value="My items" /> </p:submenu> </p:panelMenu> </h:form> And finally the userItens managed bean. @ManagedBean @RequestScoped public class UserItens { private User user; @PostConstruct private void init() { HttpSession session = (HttpSession) FacesContext.getCurrentInstance() .getExternalContext().getSession(false); LoginManager loginManager = (LoginManager) session.getAttribute("loginManager"); if (loginManager != null) user = loginManager.getUser(); } public String addItems() { // Doesn't get here. Seems like UserFilter comes first, doesn't find // an user and redirects. } I'm using glassfish and session timeout is now on 0.

    Read the article

< Previous Page | 54 55 56 57 58 59 60 61 62 63 64 65  | Next Page >